简体   繁体   中英

how to Pass param to jsp:include

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>

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}

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%>" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM