2 Replies Latest reply on Apr 25, 2012 11:44 AM by fpalma

    How to load the form values automatically?

    fpalma

      Hi all!

       

      I have done a servlet to manage one form, but when I want to get the values introduced by the user, I have to access to the parameter of the form and update manually the class corresponding to the parameter. This is my code:

       

      When the jsp file is loaded, the user sees the default value from the class "priceIncrease":

       

          <input name="increasepercent" path="percentage" value="${priceIncrease.getPercentage()}" />

       

      When the method doPost is called by the form, the class "priceIncrease" is not updated with the value modified by the user, so I have to do this:

       

          String increase1 = (String) request.getParameter("increasepercent");                     // access to the parameter of the form

          PriceIncrease increase2 = (PriceIncrease) contexto.getAttribute("priceIncrease"); // access to the corresponding class

          increase2.setPercentage(Integer.parseInt(increase1));                                            // update the class

       

      How can I update the corresponding class (priceIncrease) automatically?

       

      Thank you very much

      Fran