2

I have two files. choose.jsp and little.jspf

choose.jsp

<c:import url="little.jspf">
    <c:param name="his" value="${param.choice}"></c:param>
</c:import>

little.jspf

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<br />
this is little.jsp <br />
I just heard that somebody here said ${param.his} is important.

Output

output is I just heard that somebody here said ${param.his} is important. But when I change the .jspf to .jsp it compiles fine. Is it not possible to pass parameter to .jspf file ?

dono
  • 149
  • 1
  • 4
  • 16

1 Answers1

2

A .jspf file is supposed to be statically included (with the <%@include %> directive) inside another JSP. Not dynamically included or imported.

I would create a JSP tag file instead of using c:import.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • would it be wrong to just rename my .jspf file with .jsp ? seems like a simpler solution... (looks like JSP tag files are in the next chapter of my book) – dono Nov 11 '13 at 12:54
  • It's OK. Just not as elegant as a tag file. Why not read the next chapter of your book? – JB Nizet Nov 11 '13 at 12:58
  • Will do, just have to do some examples and clear everything before moving on, or i forget. – dono Nov 11 '13 at 13:03