Someone said that if I create the new folder (that will get image files when the Action class runs) under WEB-INF, it can be referenced easily in the JSP.
Now, I am not sure about creating folder under WEB-INF. Is there any easy way to create a folder and files under WEB-INF dynamically?
Your Java Classes are free to access, modify, manipulate data in the WEB-INF folder, clients however, do neither have access to these resources nor can they modify them.
So, whenever you have e.g. a picture under your WEB-INF folder, the only way to go when you want to serve it back to the client is writing a servlet that obtains it.
It is a common practice for access control. A website that offers downloads for registered users only would use this approach to restrict their resources.
JDBCSupport - An easy to use, light-weight JDBC framework -
If you don't need to restrict access, WEB-INF is a poor place to put them. Unless you are running out of an unexpanded war file (in which case this conversation is moot), you can find the file system location of the web app with ServletContext.getRealPath() and use noremal Java File I/O from there.
Joined: Jul 27, 2009
I love beer. Literally.
Just check the number responses (and notice the type of responses too ) on my two threads.
Thank you fellas.
Little more info about my requirement:
Action class creates charts using JFree chart and JSP access those chart images.
Following is the current setup.
At Java class:
... and at the JSP:
This setup works fine with Tomcat as webapps/<applicationName>/charts is accessible there. When we move this to WebSphere, not sure what needs to be changed.
you can find the file system location of the web app with ServletContext.getRealPath()
Action class calls another standard java class that creates images. I am clueless how to use ServletContext.getRealPath there.
Update: I retrieve following paths by using File(System.getProperty(dir)).getCanonicalPath(); Tomcat: C:\Program Files\apache-tomcat-6.0.18\bin WebSphere: C:\Program Files\IBM\Rational\SDP\6.0\runtimes\base_v6\profiles\default
Joined: Jul 27, 2009
Please do not cross-post the same question in multiple forums.
Sure, Sheriff. I thought, since this second part of my question related to Servlets, I should post it here. I feel stupid for not knowing the rules.
I'll be careful. Thanks for locking that thread for me. I was thinking of leaving a note there.