Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Preventing html from direct access

 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The term "call" has no meaning in this context. Do you mean that you are forwarding to the JSP and HTML resources?
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anything within WEB-INF cannot be directly accessed from the browser.
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic