People are working on web applications in jsp and servlets. Myjsp.jsp has my list
from the list & lt; String & gt; Sex list = (list & lt; string & gt;) request.getAttribute ("sex list"); & Gt%;
And put it in the html tag in the combo box like this
Gender: & lt; / Td> & Lt; Td> & Lt; Select name = "gender" & gt; For & lt;% (String I: Sex List) {%> & Lt; Option value = "& lt;% = i% & gt;" & Gt; & Lt;% = i% & gt; & Lt; / Options & gt; & Lt;%}% & gt; & Lt; / Select & gt; & Lt; / TD & gt;
But now I want to select the items selected from the database using JSTL and I want to know how to return or get this selected item. Also help
You must include it in the form and post it in servlet:
selection.jsp:
& lt; Form action = "display.jsp" method = "received" & gt; & Lt; Select name = "gender" & gt; & Lt; C: forEach item = "$ {sexList}" var = "gender" & gt; & Lt; Option value = "$ {sex}" & gt; $ {Sex} & lt; / Options & gt; & Lt; / C: foreach & gt; & Lt; / Select & gt; & Lt; Input type = "submit" value = "submit" /> & Lt; / Form & gt;
display.jsp
& lt; C: set var = "sex" value = "$ {param.sex}" scope = "page" /> // Selected gender & lt; Sql: query var = "person" & gt; * Choose * from that person where gender =? & Lt; Sql: Ultimate value = "$ {gender}" /> & Lt; / SQL: Query & gt;
Comments
Post a Comment