tags:

views:

1673

answers:

6

I am using "jsp:include" to include a static file in one of my jsp files. It works fine when the static html file is located inside the application folder. However if its kept outside the application folder it is not included in the JSP file.

Note: I have created a context for the folder where the static file is saved and I m able to view the html file with direct url.

Please help..

+2  A: 

You can only use jsp:include for resources inside your web application context. You will need to either use java.io.File or similar to load from a file system path, or ClassLoader.getResource to load a resource from the classpath.

Peter Hilton
Hi Peter Hilton, thank you for the suggestions. I have used c:import tag to solve this problem.
Pratheeswaran.R
A: 

Just out of interest - what is the reason for wanting to do this? - there may be an alternative approach.

I suspect that you want to have some configuration that is independent of the WAR file, and is unique to each environment that the WAR is deployed to.

belugabob
Hi Belugabob,I have all the JSPs under a war and I want to include a static html file (say something like helpcard) within the JSP file. I have these html files under another different context outside the war file. I have solved this using c:import
Pratheeswaran.R
+3  A: 

I have solved this problem using the c:import tag.

To define the dynamic URL I have used the bean:define tag. Thank you friends for the suggestions and help.

Pratheeswaran.R
A: 

You Could Also Try Using IFrame.

Shine
A: 

See this JSP Include directive example

servlet
+1  A: 

Added benefit of the <c:import> method is that you can set the encoding using the charEncoding attribute. You can't do this with either <%@include%> or <jsp:include> statements.

Matthijs Bierman