• Post Reply Bookmark Topic Watch Topic
  • New Topic

Jsp under WEB-INF  RSS feed

 
Kousik Majumder
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a query regarding putting the Jsp files under WEB-INF folder.
It is known that any files under WEB-INF folder is not accessible outside WEB-INF. Then what is the use of putting the jsp files under WEB-INF if I can not use it ? Even if it has to access some image files it has to go through WEB-INF which will not work.

Please give a scenario where I should put my jsp under WEB-INF.
 
Devaka Cooray
Marshal
Posts: 5565
712
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Contents in the WEB-INF directory are not directly accessible - using RequestDispatcher, you can dispatch the requests to the JSPs in your WEB-INF directory.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kousik Majumder wrote:Then what is the use of putting the jsp files under WEB-INF if I can not use it ?

In a properly structured modern web application, JSPs should never be directly addressed. Rather, their page controller servlets are accessed and the the JSP is forwarded to. Putting the JSPs under WEB-INF guarantees that they will never be directly addressed.

If you are not following best practices and addressing JSPs directly, then they cannot go under WEB-INF.

See this article for information on web application structure best practices.

Even if it has to access some image files it has to go through WEB-INF which will not work.

Incorrect. Image files and other client-addressable resources do not get placed with the JSPs under WEB-INF.

Please give a scenario where I should put my jsp under WEB-INF.

When you follow best practices.
 
Kousik Majumder
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot you both Devaka and Bear.
My conception is clear now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!