• 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

Preventing direct access to an HTML page

 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic