2 Replies Latest reply on Nov 15, 2001 7:14 AM by Jochen Cordes

    Listen JSP

    krami Newbie

      ich habe eine Frage, wie kann man in JSP eine Liste Dynamische generieren, ich meine:

      kann man bei diese input die name als Array definieren?
      wenn ja, wie kann man diese Array setzen?



        • 1. Re: Listen JSP
          Peet Denny Newbie

          Erm, I'm not sure that I understood the question correctly (Babelfish isn't perfect :^D ).
          I gather what you are asking is:
          "If I can create a dynamic list like this:
          < input type="text " name="QTY[ ] " size="5 " VALUE = " < %=warenkorb,getQTY(i)% > " >

          How can I get the name to be dynamic too? "

          If that is your question, then this is my answer:

          One idea would just be to concatenate the name to the array value like this:

          But I wonder how you would then read the values in your servlet. The way I do it is like this:

          < input type="text " name="QTY" size="5 " VALUE = " < %=warenkorb,getQTY(i)% > " >
          Then I can get all the values that the user entered in the form of an array. like this:
          String quantities = request.getParameterValues("QTY");

          Hope this helps ?!
          Bis bald
          ps (try babelfish http://world.altavista.com/tr)

          • 2. Re: Listen JSP
            Jochen Cordes Novice

            Hi !

            You can create a dynamic list like this

            <% for (int i=0; i < myArray.length; i++){ %>
            <input type="text" name="QTY" size="5" VALUE="<%=myArray%>">
            <% } %>

            If you're using the same name for input-fields you get an array of values (for example in your servlet). You have no other chance then to iterate through your array, setting them individually.