Deploying Java application via Java Web Start(.jnlp), directory permission and location? - java-web-start

In my jnlp file I need to use nativelib tag.
<nativelib href="lib/windows/alib.dll"/>
is that href refer to the directory on my server? what if my jar application looks for the alib.dll inside it's bin folder? how would I indicate this?
will there be any issues with write permission on where the application is installed (where is the default jnlp installation folder and how does the user change this?)

Related

file created using getRealPath gets created on .metada/.plugins folder not in WebContent project folder

I am trying to create a file using below code in a Servlet:
File outfile= new File(servletContext.getRealPath("/Output/output.xml"));
OutputStream os = new FileOutputStream(outfile);
from a J2EE Application (CallMain) and the file gets created in deployed temp path
.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\CallMain\Output
Actually I want the file to be created in current project folder: WebContent.
Actually when you ran the servlet within eclipse using the embedded tomcat server
getServletContext().getRealPath("WEB-INF")
Gives you this
D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\DynaServletProject\WEB-INF
But when you ran the servlet from standalone Apache Tomcat:
getServletContext().getRealPath("WEB-INF")
This gives you
D:\apache-tomcat-7.0.33\webapps\DynaServletProject\WEB-INF
While in eclipse you can give the absolute path i dont think this is the best approach though
By default, your application stages and runs from a directory buried in the workspace's .metadata directory. That is the "real path" at runtime. Check your Server's configuration for options regarding deploying the app directory from the workspace folders.

Problems with relative paths in Eclipse.

I am trying to use relative paths in a Dynamic Web Project in Eclipse. I am NOT using them in the Servlet, but in another class that is called by the Servlet. The file I am trying to access to is a property file located in
MyProject/WebContent/WEB-INF/propertyFile.properties
I have tried almost every relative path...
WebContent/WEB-INF/propertyFile.properties
/WebContent/WEB-INF/propertyFile.properties
./WebContent/WEB-INF/propertyFile.properties
MyProject/WebContent/WEB-INF/propertyFile.properties
/MyProject/WebContent/WEB-INF/propertyFile.properties
WEB-INF/propertyFile.properties
/WEB-INF/propertyFile.properties
./WEB-INF/propertyFile.properties
...and so on...what can I do?
Thanks in advance!
You nee to understand that file IO read files, from the filesystem, and relative to the directory from which the JVM (i.e. your web container) is started.
Remember that, once your app is deployed to production, there won't be any MyProject or WebContent folder. That's what exists on your development machine. The only thing that will exist in production is the war file deployed in the application server.
What you actually want is to load a resource, located in the deployed web application (i.e. which is inside your war file).
To do that, you must use ServletContext.getResourceAsStream():
InputStream in = servletContext.getResourceAsStream("/WEB-INF/propertyFile.properties");

Deploying GWT in localhost and see that webpage

I am a new user in GWT and I want to deploy one of existed samples in my localhost. I could run the example by eclipse and get the result. But I need to deploy that example in my localhost (IIS). How can I do this?
Copy the contents of your project's war directory to your server's document root. You could create a folder there, mproject for example. Then load your project on a web browser: localhost/mproject to view.
Go into your project's war directory For EX:
C:\workspace\HelloWorld\war
Select all the files & folders available inside war directory.
Zip all the selected files & folders in a file called HelloWorld.zip.
Rename HelloWorld.zip to HelloWorld.war.
Deploy it to the server

404 -resource under sub-directory not found in eclipse

I am able to access a resource(say test.html) only when it is directly under WebContent in eclipse.If i place it in WEB-INF or WEB-INF/jsp the IDE shows error 404-requested resource is not available.
http://localhost:8080/MyApp/test.html (This works when test.html is under WebContent and not any of it's subdirectory)
When it is in WebContent/WEB-INF
Right click-run takes to the below URL which shows 404-resource not available
http://localhost:8080/MyApp/WEB-INF/test.html
How do i access it by placing "test.html" in WEB-INF or WEB-INF/jsp?
All configurations are default with no restrictions specified in web.xml and using Tomcat 7 as the web server
To prevent access to specific files. You cannot access /WEB-INF/ directory from outside the server itself. If you want to create subdirectory create them under
WebApp/
-index.jsp
-YourSubdirectory/
--test.jsp
test.jsp can be accessed via localhost:8080/MyApp/YourSubdirectory/test.jsp
Files at WEB-INF directory cannot be accessed directly from browser. This is the basic restriction.
However content of this directory could be accessed at application level. Web container provides such opportunity.
For example, if you using SpringMVC, you can map some URL to the file at WIB-INF directory and it will work correctly.

Where is the deployment directory in Eclipse?

I'm developing a web app in Eclipse. where is the deployment directory tree situated? In the Apache directory structure or some sub-directory tree structure in my Java workspace tree? I ask because I went browsing the directory tree(s) when an update to my tutorial app didn't work and, assuming that the src subtree represents my development directory tree I was hoping that the WebContent/WEB-INF subtree would contain my deployment tree (I also assumed that when I run the app the deployment directory structure would be automatically created for me), but I found the WEB-INF empty.
I'm developing a web app in Eclipse. where is the deployment directory tree situated? In the Apache directory structure or some sub-directory tree structure in my Java workspace tree?
It all depends on how your Tomcat Server is configured. The default should be: .metadata/.plugins/org.eclipse.wst.server.core/tmp0. But you can change this in the Tomcat server configuration. To do so, go to the Servers view, double-click on your Tomcat server and modify the Server path and Deploy path:
I personally use the Tomcat installation for full control (and the default deploy path i.e. wtpwebapps).
If it is not possible to change something in the "Server Locations" section, then see this answer on how to change that.
Usually, Eclipse compiles into directories in the workspace. Once the build is complete, this directory is then copied by a deployment plugin into the directory Tomcat uses.
If you use the WTP plugin bundled in the Eclipse Java EE download, the deployment location is configurable in the server's property page within eclipse.