File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "file include in servlet" Watch "file include in servlet" New topic

file include in servlet

Chuck Lowry

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

Joined: Mar 06, 2001
Posts: 13459

request.getRequestDispatcher( "/foo/bar.html" ).include( request, response );
[ Whoops, wheres my brain this morning? ]
[ June 11, 2002: Message edited by: David O'Meara ]
I agree. Here's the link:
subject: file include in servlet
jQuery in Action, 3rd edition