java - how to send checkbok state from included JSP page to another JSP page -
i have 3 jsp pages first 1 contains checkbok created using boucle. page1.jsp :
for(int i=0; i<5; i++){ %> <input type="checkbox" name="selection" value="box"+<%=i %> /> %>
the second 1 (page2.jsp) includes first 1 , send state of checkbox third 1 (page2.jsp).
page2.jsp :
<jsp:include page="page1.jsp"> <jsp:param name="type1" value="<%=request.getparametervalues(\"selection\")%>" /> </jsp:include>
page3.jsp
<%string valuebd=request.getparameter("type1");
thank you
firstly, recommend don't use scriptlets. litter code throughout jsp pages , makes application extremely difficult manage. should use el (expression language). allows add functionality jsp page without using java code, example:
<c:if test="${parametervalue}"> <p>${parametervalue}</p> </c:if>
onto problem. recommend passing value onto server using post request type. server, can redirect desired jsp page. shouldn't thinking literally passing values between jsp pages. breaks paradigm you're working under when make web based applications.
<input type="hidden" name="value" value="${parametervalue}"/>
by placing element inside form
element, , submitting form, pass servlet server. next, in java code, can use requestdispatcher
pass next jsp file.
string value = request.getparameter("value"); requestdispatcher dispatcher = request.getrequestdispatcher("page2.jsp"); dispatcher.forward(request, response);
this make value available in "page2.jsp".
Comments
Post a Comment