Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to Pass param to jsp:include

Tags:

java

jsp

This is my part of jsp file.i am struggling to set param value to SalesClientDetails.jsp.i am not using this style <% %>. How to pass param i tried using jsp:expression but no success.

<jsp:scriptlet>
    if (request.getParameter("clientid") != null) {
        String clientid = request.getParameter("clientid");
</jsp:scriptlet>

        <jsp:include page="SalesClientDetails.jsp">
            <jsp:param name="clientid" value= />
        </jsp:include>

<jsp:scriptlet>
    }
</jsp:scriptlet>
like image 712
Sureshkumar Menon Avatar asked May 01 '11 19:05

Sureshkumar Menon


2 Answers

Simple, do not use scriptlets, also not in flavor of JSP tags. Use JSTL/EL.

<c:if test="${not empty param.clientid}">
    <jsp:include page="SalesClientDetails.jsp" />
</c:if>

And in the SalesClientDetails.jsp just get it by

${param.clientid}
like image 58
BalusC Avatar answered Sep 28 '22 17:09

BalusC


You've created the variable clientId within a scriptlet, which means that it's a Java variable (versus a value in the page context). So you have to retrieve it with <%= %>:

<jsp:param name="clientid" value="<%=clientId%>" />
like image 25
Anon Avatar answered Sep 28 '22 18:09

Anon