How to pass jsp parameter: enable

This is my part of the jsp file. I am trying to set a parameter value for SalesClientDetails.jsp.i, not using this <%%> style. How to pass the parameter that I used using jsp: expression, but without 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> 
+6
source share
2 answers

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

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

And in SalesClientDetails.jsp just get it

 ${param.clientid} 
+4
source

You created the clientId variable inside the script, which means that it is a Java variable (compared to the value in the context of the page). So you need to get it with <%= %> :

 <jsp:param name="clientid" value="<%=clientId%>" /> 
+1
source

Source: https://habr.com/ru/post/887067/


All Articles