Search code examples
javajspjsp-fragments

.jspf not compiling even though in jsp


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 ?


Solution

  • 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.