• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Public folder in JavaEE website

 
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody.
I started using java for web apps a few months ago and i still have much to learn. I have one simple question to which i found no answer on the internet.

We all know the directory structure of a webapp

/
/WEB-INF
/WEB-INF/lib
/WEB-INF/classes

Files in the root directory are available via HTTP to the end user. But it would be such a mess to put DOZENS of images and other stuff just in one directory!
Isn't there a way to tell the servlet container to have more public dirs? Besides, many javascript applications (like TinyMCE editor) have their own directory structure and many .js files would end not being in a public folder.

Any suggestions?

Thank you in advance.
 
Saloon Keeper
Posts: 7611
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can create directories in the root directory as you please: /images, /css, /js, ... They will all be publicly accessible.
 
Martin Bechtle
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, excellent!
And what about making them inaccessible for end user? What's the best practice? CHMOD them, configure some XML on the server or placing them in WEB-INF/...?
 
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
Any resource you do not want to be directly accessible via URL (JSPs for example, which should only be accessed via their page controllers) can be placed under WEB-INF.
 
Martin Bechtle
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All clear then. Thank you for your precious replies.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
If I put my jsp content inside the WEB-INF how can access that page from servlet to redirect to that jsp.
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Miku Ranjan wrote:Hi,
If I put my jsp content inside the WEB-INF how can access that page from servlet to redirect to that jsp.


You don't. All access to the JSP should be through its page controller. Please read this article for more information.
 
Miku Ranjan
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,
Thank for the article but which part of the article I should look for my answer.
 
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
Read the whole thing. Just reading a small part will be of little use.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic