• 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

Jsp under WEB-INF

 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
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

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: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot you both Devaka and Bear.
My conception is clear now.
reply
    Bookmark Topic Watch Topic
  • New Topic