Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I forward to HTML in WEB-INF?  RSS feed

 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use tomcat on XP. If I forward of include a Servlet I just forward or include "/servlet/directory.servlet" but I tried to put a html in WEB-INF and I forward/include to "/WEB-INF/any.html" I failed, but if I forward/include html in other directory, no problem. So I wonder how I can forward/include my html in WEB-INF directory.
My aim of this is not letting people guess the resourse url (html) as they can't get those htm in WEB-INF. Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servlet API specifically states that servers are forbidden to directly serve any file in WEB-INF. All part of the over-all security plan. Forward/include expects the destination to be executable so HTML doesn't work.
You could easily make a page serving bean that just spits out the HTML content from any location - if you make it have application scope, it could cache popular pages.
Bill
 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh. Is it Java Bean? I have no background knowledge of Java Bean at all, please would you tell me where have tutorial on this topic about getting html from place to place?
(But with this technique, people can still guess the location of my html?)
Thanks
 
Zakaria Haque
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In many cases people just replace the word "class" with "bean". Its an involutary recreational process due to the fatigue of using the term "class"
What William was telling you is, have a java class that takes a filename and and has a method to write the content of the file (and may be specifying content type using ServletContext). As he mentioned it has the added benefit of caching, in case if you need it.
right William?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly - JavaBeans as used here is just a method naming convention that gets you some extra convenience when working with JSP and some other APIs. It is very widely used so you should read up on it - there are tutorials all over - do a search on Yahoo.
Don't be put off by the complex JavaBeans conventions used in building GUIs - at the servlets-JSP level, only the simplest parts of the convention are used.
Since code in a servlet can read files from anywhere on your system, nobody will be able to get them directly.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!