This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes file include in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "file include in servlet" Watch "file include in servlet" New topic
Author

file include in servlet

Chuck Lowry
Greenhorn

Joined: May 29, 2002
Posts: 13
I would like to include a HTML file in my servlet's output. I understand that I could just open the file from the filesystem, but I do not want to lock myself into a path I will have to change if I change servers. What I really desire is a way to include the file in my servlet in such a way that as long as the relative URL is maintained, the file will be accessable, much the same way as the JSP <@ include file = '/foo/bar.html' %> works.
Thanks for your help.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Use:
request.getRequestDispatcher( "/foo/bar.html" ).include( request, response );
[ Whoops, wheres my brain this morning? ]
[ June 11, 2002: Message edited by: David O'Meara ]
 
jQuery in Action, 2nd edition
 
subject: file include in servlet