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 Java Interview Guide this week in the Jobs Discussion forum!
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 ]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: file include in servlet
It's not a secret anymore!