Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Including html file outside web project

 
SANJAY KUMAR
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I have a html file and want to include in my web project. As this file get dynamically generated so I can not put inside in webproject.
I am using jsp:include but it always add context path before absolute path so I am getting no file found error.
Any idea how to html include which is outside web project?
 
SANJAY KUMAR
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If any one has difficulty to understand my prob I will try to explain in better way.
Please let me know...
 
Cory Wilkerson
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the Java Server Pages specification:
------------------------------------
JSP.5.4 <jsp:include>
A <jsp:include .../> element provides for the inclusion of static and dynamic resources in the same context as the current page.
See Table JSP.1-10 for a summary of include facilities.
Inclusion is into the current value of out. The resource is specified using a relativeURLspec that is interpreted in the context of the web server (i.e. it is mapped).
-------------------------------------
That said, you may want to open up an HttpURLConnection to said resource, and basically channel it into the jsp's outputstream.
That may/should do the trick.
Cory
[ February 06, 2003: Message edited by: Cory Wilkerson ]
 
Sudd Ghosh
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the JSP specs encourages us to stay within the webapp domain. But to go to some other directory, servlets may be of more help, where you can get the ServetRequest.getRequestDispatcher().include() method for a non-webapp relative path or HttpservletResponse.sendRedirect() for an absolute URI.
I've never tried doing this, but in case you want to try, you may include a servlet, pass the file name as a request param to this servlet, then from the servlet (after reading the request param) you can try to include this file.
Thanks, Sudd
 
SANJAY KUMAR
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can not use send redirect as I want to include one html file which is lying some where in C:\ drive. But web server adds context root when it tries to include file. Web server add as it works only for project which is in the web-app.
So I need a trick by which I can include file which is outside web-app.
see my file is
C:\temp\abc\new.html
when I am tring to include in my jsp I am getting error
/<context-root>/C:\temp\abc\new.html could not found as web server puts /<context-root>/ but default as it thinks file is lying some where in web-app.
Any suggestion is appreciable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic