Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Preventing direct access to an HTML page

 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a requirement where I need to redirect to an HTML page from a servlet. The HTML page should not be directly accessible otherwise. How can I achieve this? Please note, using JSP instead of HTML is not an option.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put your html file inside the WEB-INF folder of your web application. That's the only way (I know of) that you can prevent the user from directly accessing a web resource on your server!

Of course it also means you cannot use a response.redirect() to access the web page and would have to use a forward() instead. In fact I don't think there is any way you can hide a resource to which you redirect since request for any redirected resource comes ultimately from the browser itself.

Just out of curiosity - why can't you use jsp instead of html? Good pattern would dictate that all your files be '.jsp' anyways?
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sam. Let me clarify the requirement a bit. Actually its a SWF (Flash player file) to which I need to move from servlet and not HTML. I said HTML in the question, to keep it familiar and simple.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic