• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file include in servlet

 
Chuck Lowry
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use:
request.getRequestDispatcher( "/foo/bar.html" ).include( request, response );
[ Whoops, wheres my brain this morning? ]
[ June 11, 2002: Message edited by: David O'Meara ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic