java - How to pass key-value pair from jsp to servlet? -
I have a faculty institution, subject and mark unit, each faculty has a list of elementary topics
When the applicant wants to apply for some faculty, then he should enter his marks in the initial subjects and his school diploma (college, whatever).
And I like this value as key-value pair such as subject-mark .
So for now I have apply.jsp page two list & lt; Subject & gt; In the list , go to the form of request attributes in the all topics - this is for the diploma, and in another list Faculty topics - they are preliminary
My apply.jsp Pages listed below:
& lt;% @ Page language = "java" contentType = "text / html; charset = UTF-8" page encoding = "UTF-8"%> & Lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Transcription // N" "http://www.w3.org/TR/html4/loose.dtd"> & Lt;% @ taglib prefix = "c" yur = "http://java.sun.com/jsp/jstl/core"% & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" & gt; & Lt; Title & gt; Apply for $ {faculty.name} & lt; / Heading & gt; & Lt; / Head & gt; & Lt; Body & gt; You are applying to the client for the Faculty View! & Lt; H1 & gt; $ {Name} & lt; / H1> & Lt; Ul & gt; & Lt; Li & gt; & Lt; Label & gt; Name of Faculty: & lt; / Labels & gt; & Lt; C: Out value = "$ {name}" & gt; & Lt; / C: Out & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; Label & gt; Total seats: & lt; / Labels & gt; & Lt; C: out value = "$ {total_seats}" & gt; & Lt; / C: Out & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; Label & gt; Budget Seat: & lt; / Labels & gt; & Lt; C: Out value = "$ {budget_seats}" & gt; & Lt; / C: Out & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; Form action = "controller" method = "post" & gt; & Lt; Input type = "hidden" name = "command" value = "applicable faculty" /> & Lt; Input type = "hidden" name = "show" value = "wrong" /> & Lt; Input type = "hidden" name = "faculty subjects" value = "$ {faculty topics}" /> & Lt; Input type = "hidden" name = "all topics" value = "$ {all topics}" /> & Lt; H1 & gt; Your starting issue & lt; / H1> & Lt; Table ID = "Initial" & gt; & Lt; C: forEach var = "faculty subject" item = "$ {faculty topics}" & gt; & Lt; TR & gt; & Lt; Td> & Lt; C: Out value = "$ {faculty.Subject.name}" & gt; $ {FacultySubject.name} & lt; / C: out & gt; & Lt; / TD & gt; & Lt; Td> & Lt; Input type = "text" name = "primary mark" value = "" /> gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / C: foreach & gt; & Lt; / Table & gt; & Lt; H1 & gt; Your Diploma Issue & lt; / H1> & Lt; Table id = "diploma" & gt; & Lt; C: forEach var = "subject" item = "$ {allSubjects}" & gt; & Lt; TR & gt; & Lt; Td> & Lt; C: Out value = "$ {subject.id}" & gt; $ {Subject.name} & lt; / C: Out & gt; & Lt; / Td> & Lt; Td> & Lt; Input type = "text" name = "diploma mark" value = "" /> gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / C: foreach & gt; & Lt; / Table & gt; & Lt; P & gt; & Lt; Input type = "submit" value = "OK" & gt; & Lt; / P & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt; So how should I convert it to get the required functionality?
PS If this is easy to do - actually in the topic id field for the required information in the insert
Please try something like the following:
Lt; C: Each Variable = "Faculty Subject" item = "$ {faculty topics}" & gt; & Lt; TR & gt; & Lt; Td> & Lt; C: Out value = "$ {faculty.Subject.name}" & gt; $ {FacultySubject.name} & lt; / C: out & gt; & Lt; / TD & gt; & Lt; Td> & Lt; Input type = "text" name = "topic_ $ {faculty.Subject.id}" value = "" /> gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / C: foreach & gt; And do the following in your servlet:
Maps & lt; String, string []> Parametermap = request.getParameterMap (); (String key: parametermap.cset ()) {if (key.startsWith ("subject_")) / / what ever you want here}} Hope that helps is. / P>
Comments
Post a Comment