aspose file tools*
The moose likes Servlets and the fly likes Public folder in JavaEE website Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Public folder in JavaEE website" Watch "Public folder in JavaEE website" New topic
Author

Public folder in JavaEE website

Martin Bechtle
Greenhorn

Joined: Nov 17, 2011
Posts: 3
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.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
You can create directories in the root directory as you please: /images, /css, /js, ... They will all be publicly accessible.
Martin Bechtle
Greenhorn

Joined: Nov 17, 2011
Posts: 3
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/...?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Martin Bechtle
Greenhorn

Joined: Nov 17, 2011
Posts: 3
All clear then. Thank you for your precious replies.
Miku Ranjan
Ranch Hand

Joined: Oct 11, 2011
Posts: 98
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

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

Joined: Oct 11, 2011
Posts: 98
Hi Bear,
Thank for the article but which part of the article I should look for my answer.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Read the whole thing. Just reading a small part will be of little use.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Public folder in JavaEE website
 
Similar Threads
source path help
Apache/Tomcat simple applet problem
.war files containes??
Importing Eclipse project in to MyEclipse 6.6
jspsmartupload.jar