my dog learned polymorphism*
The moose likes JSP and the fly likes Including html file outside web project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Including html file outside web project" Watch "Including html file outside web project" New topic
Author

Including html file outside web project

SANJAY KUMAR
Greenhorn

Joined: Mar 27, 2002
Posts: 25
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?


SCJP, SCWCD , SCBCD
SANJAY KUMAR
Greenhorn

Joined: Mar 27, 2002
Posts: 25
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

Joined: Aug 14, 2001
Posts: 84
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

Joined: Oct 23, 2002
Posts: 187
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


SCJP 1.4, SCWCD, SCBCD 1.3
SANJAY KUMAR
Greenhorn

Joined: Mar 27, 2002
Posts: 25
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Including html file outside web project