• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Creating a new folder under WEB-INF

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello gurus,
This is in continuation on my earlier post https://coderanch.com/t/455889/Websphere/Image-location-Websphere

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?

I am completely lost on this issue.

Get me some idea, your next be on me. :-)

Thanks.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not something you would do in a JSP, so moved to the Servlets forum.
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Johnny Brown
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow..
I love beer. Literally.
Just check the number responses (and notice the type of responses too ) on my two threads.
Thank you fellas.

Fun apart,
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
 
Johnny Brown
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear Bibeault:

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.
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What the problem with using getRalPath()?
 
Johnny Brown
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, friends.
I got it resolved using getRealPath().

Thanks for the tip, Sheriff. Used it and resolved the issue.

Bear Bibeault wrote:What the problem with using getRalPath()?


To be honest with you, laziness was the problem. Had to think the way to use it.
 
rubbery bacon. rubbery tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic