This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Preventing html from direct access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Preventing html from direct access" Watch "Preventing html from direct access" New topic
Author

Preventing html from direct access

Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
If i put a jsp file into web-inf and then try to call it from servlet,it is happening.But,if i am putting a html page into web-inf and if i am trying to call that from servlet,it is saying requested resource is not available.Any suggestions?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

The term "call" has no meaning in this context. Do you mean that you are forwarding to the JSP and HTML resources?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
yes Bear,I meant forwarding only.
Actually,from servlet i am able to forward to html page and jsp page both.
Earlier,i was going from servlet to jsp through request dispatcher,then from jsp to other html on button clicking,so control was not going to that html page.
So,i have reached to a conclusion :
If we are going to other page(html or page) through button click,link click etc.,then other resource must be outside web-inf even if first resource is also inside web-inf.
Explanation:
IF,
web-inf/a.jsp--->web-inf/b.jsp, on button click we can't go to b.jsp,it has to be outside web-inf,if we want to access on button click.
Please tell me if i am accurate in my decision.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Anything within WEB-INF cannot be directly accessed from the browser.
Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
Hi Bear,
thanks for the reply.But suppose the case :

web-inf/a.jsp-->some servlet(b.class)
If this flow is working fine then why the case which i have posted earlier is not working fine.while both b.class(servlet) and b.jsp are in web-inf only.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

First, whenever I see this I point it out because I've seen people get hung up on it. The directory WEB-INF must always be spelled with upper case letters.
A directory named 'web-inf' has no special meaning in Java web application.
This happens enough that it is the textbook example used in:
http://faq.javaranch.com/java/AvoidRedHerrings

If you're saying here, that a.jsp is being allowed direct access to a browser (and the directory is really named "WEB-INF") I would tell you that you are wrong.
web-inf/a.jsp-->some servlet(b.class)

Nothing under WEB-INF is directly available to the web.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Preventing html from direct access
 
Similar Threads
jar files
Where to place non java files in a WAR archive?
multiple servlets
requested resource (first.jsp) not available
html vs servlet