Jasper exception occurring while trying to include a jsp page with dynamic URL

572 views Asked by At

Please look at the following code snippet and let me know what's wrong with that as I'm getting the below errors when trying to run it.

org.apache.jasper.JasperException: The jsp:param action must not be used outside the jsp:include, jsp:forward, or jsp:params elements

org.apache.jasper.JasperException: Expecting "jsp:param" standard action with "name" and "value" attributes

Here's the code I'm trying to execute

<%
    String contextRoot = request.getContextPath();
    String stdInfoViewURL = contextRoot.concat("jsp/student/ViewStudentDetails.jsp"):
%>

<html><body>

<jsp:include page="<%=stdInfoViewURL%>" flush="true">

    <jsp:param name="studentId" value="ABC123" />
    <jsp:param name="studentName" value="MARK TAYLOR" />

</jsp:include>

</body></html>

I tried even declaring the java objects in following manner too. But no luck.

<%!
    String contextRoot = request.getContextPath();
    String stdInfoViewURL = contextRoot.concat("jsp/student/ViewStudentDetails.jsp"):
%>
1

There are 1 answers

0
NAK On BEST ANSWER

Omit the contextRoot from your stdInfoViewURL and just do

String stdInfoViewURL = "/jsp/student/ViewStudentDetails.jsp":