| Author |
JSP,HTML pages should be outsite WEB-INF
|
Monica. Shiralkar
Ranch Hand
Joined: Jul 07, 2012
Posts: 182
|
|
Should JSP and HTML pages inside Web INF or Outsite WEB INF. I have seen some applications where JSP and HTML pages are kept inside web info too.
Generally java classes are inside SRC, web.xml is inside web-info.and JSP pages are in WEB Content.but can JSP be in web-inf too?
|
 |
harshvardhan ojha
Ranch Hand
Joined: Jul 26, 2007
Posts: 155
|
|
Everything outside WEB-INF is publicly available no authentication is applied on that, but all resources inside WEB-INF is secured. You can keep static pages outside WEB-INF and dynamic pages like profiles, accounts inside WEB-INF.
Please cross check i might be wrong.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19214
|
|
While it's true anything inside WEB-INF will produce a 404 error when accessed directly, this doesn't mean that JSP files within WEB-INF are not accessible at all. They can be included or forwarded to using JSTL and RequestDispatcher. You can also create a servlet-mapping for them.
Also, it's not 100% true that everything outside WEB-INF is publicly available without any authentication. That's true by default, but it's possible to specify a security constraint for any content.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Swetha Bhagavathula
Ranch Hand
Joined: Jan 04, 2011
Posts: 112
|
|
|
instead we can JSP and HTML files place it in a seperate folder parallel to WEB-INF...WEB-INF is private folder.. if I am not wrong...Also Servlets are placed inside WEB-INF\classes and they need compilation for every modifications done where as JSp and HTML files modifications are recognised by container automatically.......If am wrong please correct me...........
|
SCJP5
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56150
|
|
|
It is most proper to place JSP pages inside WEB-INF so that they are not directly access lie except through their page controllers. See this article for more info on proper web app structure.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
BalaMurali dhar
Ranch Hand
Joined: Apr 14, 2012
Posts: 60
|
|
|
JSP & HTML should be inside the WEB-INF
|
 |
Reeny Ubeja
Greenhorn
Joined: Jul 22, 2012
Posts: 2
|
|
Jsp,html should be outside the web-inf because server always looks for class files n web.xml inside the web-inf->classes folder....
|
 |
BalaMurali dhar
Ranch Hand
Joined: Apr 14, 2012
Posts: 60
|
|
|
whenever your creating a project this is the root directory create a project folder. Inside the Project folder create WEB-INF Folder, classes folder & Lib folder . Inside the classes folder you write java class. Inside the Lib you have to put jar file. Inside the WEB-INF you can put web.xml, JSP & HTML
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56150
|
|
BalaMurali dhar wrote:JSP & HTML should be inside the WEB-INF
That is too simplistic and not correct.
Firstly, HTML files are almost always directly addressed -- as they have no active components they do not need a page controller. So HTML file are generally outside the WEB-INF.
JSPs, which should never be directly addressed, should be inside WEB-INF so that they must be accessed via their page controllers.
|
 |
 |
|
|
subject: JSP,HTML pages should be outsite WEB-INF
|
|
|