Results 1 to 13 of 13
  1. #1
    ras_pari is offline Member
    Join Date
    Oct 2009
    Posts
    40
    Rep Power
    0

    Angry dynamically generation of request.getParameter()

    hi..
    I have a problem ....I have a html page which is having dynamically created text box.Now i have to receive the value of this text box in jsp page.But I do not know how to set the request.getParameter() for dynamically created text box.Boz I do not what is exactly the number of text box created dynamically?.plz help me!!!

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You can use request.getParameterName() to find all the name of parameters passed with the request.

  3. #3
    ras_pari is offline Member
    Join Date
    Oct 2009
    Posts
    40
    Rep Power
    0

    Default

    See the problem is that only I do know waht is exactly the number of text box boz it is created text box dynamically.So in jsp page how many request.getParameter i set in jsp page that I do not know?

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    What do you mean by "how many request.getParameter i set in jsp page"?
    You should not have any request.getParameter calls in your JSP at all. Scriplets are old and evil.

    In a servlet, loop through all the parameter names adding the parameter names and values to, say, a map and you have all the parameter names and values.

  5. #5
    ras_pari is offline Member
    Join Date
    Oct 2009
    Posts
    40
    Rep Power
    0

    Default

    What do you mean by "how many request.getParameter i set in jsp page"?
    The answer of this question is this thai in html page text box r created dynamically so I do not know the number of text box created.So how many request.getParameter()I set in jsp page?

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Still not making much sense.
    Are you having problems with creating the textboxes or are you having problems with reading the values set in the dynamically created textboxes?

    Do you understand what the request.getParameterNames() method returns?

  7. #7
    ras_pari is offline Member
    Join Date
    Oct 2009
    Posts
    40
    Rep Power
    0

    Default

    I do not have problems with creating the textboxes .I have problems with reading the values set in the dynamically created textboxes through request.getParameter()

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    And do you know what the request.getParameterNames() method gives you then?

    Are you reading all parts of the replies I'm posting or just some parts and ignoring the rest?

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,010
    Rep Power
    20

    Default

    What is the naming structure of your dynamically created text boxes?
    Are they along the lines of "textbox_n" where n is an incremented number?
    If so you want a while loop (while (found)) starting at whatever minimum you have for n, and keep going until "textbox_" + n returns null.

    I can't remember what you get back if a textbox_n is empty (would that be null or a blank string)...

  10. #10
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Or just use request.getParameterNames() to get the names of all the parameters.

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,010
    Rep Power
    20

    Default

    The problem with that is, if the number of these things is important then you still have to loop through them to find the largest number.

    Presumably the fields (and numbers) mean something?

    Of course, as usual, we're playing Guess The Requirements...

  12. #12
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    I don't see how that is a problem. In fact even if the objective is to find the largest number (which I doubt) then that can still be done in one loop while reading the parameter names enumeration.

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,010
    Rep Power
    20

    Default

    Fair point.
    I usually see this as a collection of fields, so I find using the id first and simply grabbing the collection of parameters based on the id preferable to going through all the parameter names and then grouping them together. Personal preference...though possibly completely irrelevant to a case with a single field.

Similar Threads

  1. Replies: 0
    Last Post: 03-10-2010, 02:52 PM
  2. War file generation
    By rummy in forum New To Java
    Replies: 1
    Last Post: 02-08-2010, 12:57 PM
  3. Report generation
    By anilkumar_vist in forum Advanced Java
    Replies: 1
    Last Post: 12-14-2009, 12:26 PM
  4. String generation
    By codingisfun22 in forum Advanced Java
    Replies: 3
    Last Post: 12-03-2007, 05:43 AM
  5. Help with request.getParameter()
    By Albert in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 07-13-2007, 03:39 PM

Posting Permissions

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