Results 1 to 3 of 3
  1. #1
    raghu9198's Avatar
    raghu9198 is offline Member
    Join Date
    Dec 2008
    Posts
    32
    Rep Power
    0

    Default to retrieve multiple values from html page through jsp

    hi all,

    I have a problem while retrieving the values in jsp.In the html page I kept the set of values to be submited in a loop.But while retrieving I am able to retrieve only one set of values.I want to retrieve all the set of values submited in a loop.

    In Html I have written the code like this:

    <%

    while(true)
    {
    out.println(" <input type=checkbox name=domain value=<%=domain%>>Domain");
    }
    %>
    <input type=submit name=submit value=submit>


    In JSP I have written the code like this:

    <%
    while(true)
    {
    String domain=request.getParameter("domain");
    }
    %>
    here Iam geting the last submited value in the while loop.


    thanks
    raghu

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    you may try getParameterMap() which returns Map<String, String[]>

    assume info is object of above Map
    try to access info.get(key)[0]; info.get(key)[1]; etc... ?

  3. #3
    neeraj.singh is offline Member
    Join Date
    Feb 2009
    Location
    Delhi
    Posts
    63
    Rep Power
    0

    Default

    raghu,
    when you have more the form element of the same name then it creates an array for that element...
    like
    name will be name[]

    for you i would recommend to have like this
    for(i = 0; i<codition; i++)
    %>
    <input name = "name_<%=i%>" value=.....

    and a hidden variable with value of the count of that element...
    and
    retrieve the value in jsp like this
    name[i] = request.getParameter("name_"+i);

Similar Threads

  1. Multiple Language in my web page
    By Albert in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 09-21-2009, 01:46 PM
  2. to retrieve the webcontent from another page source
    By rameshsathasivam in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 11-25-2008, 08:41 AM
  3. Replies: 2
    Last Post: 11-09-2008, 10:49 PM
  4. To highlight multiple selected values in listbox
    By swapnanair in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 05-06-2008, 11:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •