JSTL c:import tag problem

A

alan_sec

I have a problem using JSTL tag c:import.
When i use jsp:include it works and if i use c:import i doesn't work. I
don't know what is the problem.

jsp file:

this works:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
....
<table width="100%">
<tr>
<td>
<jsp:include page="predefined/predefined1.jsp"/>
</td>
</tr>
</table>

but this doesn't:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
....
<table width="100%">
<tr>
<td>
<c:import url="predefined/predefined1.jsp" />
</td>
</tr>
</table>

predefined/predefined1.jsp
The file that is being included (predefined/predefined1.jsp) is file on
local disk.
Alan
 
S

stephen.mcelhinney

Hi Alan

Do the logs tell you whether or not they've found your taglibs? What
servlet container are you using?

Also, I've never used c:import with relative URLs, as far as I know it
requires a fully-qualified URL.

You could achieve this by doing a scriptlet. Something like

String filename = "foo.jsp";
pageContext.setAttribute("fullurl",
request.getScheme()+"://"+request.getServerName()+request.getContextPath()+"/"+filename);

and then in the import tag

<c:import url="${fullurl}" charEncoding="UTF-8"/>

(obviously change the encoding to whatever you need it to!)


Hope this gives you some ideas.

Thanks
Stephen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top