Keeping form input values

Discussion in 'Java' started by francan00@yahoo.com, Feb 19, 2008.

  1. Guest

    I am going to create a form that will have about 3 pages of inputs in
    one form.
    The first and second page will have continue button and the final page
    (3rd page) will have the submit (into database) button.

    What is the best way to forward the form inputs from each page so all
    will be submitted?

    I will use MVC architecture but dont have Struts on our Tomcat 4.1.27
    container.
     
    , Feb 19, 2008
    #1
    1. Advertising

  2. Wojtek Guest

    wrote :
    > I am going to create a form that will have about 3 pages of inputs in
    > one form.
    > The first and second page will have continue button and the final page
    > (3rd page) will have the submit (into database) button.
    >
    > What is the best way to forward the form inputs from each page so all
    > will be submitted?


    Create an object which will hold all the form inputs, and store that
    object in the user's session. You can also store state, so you know if
    the user clicks on the Back button, or tries to go to page two without
    first going to page one.

    --
    Wojtek :)
     
    Wojtek, Feb 19, 2008
    #2
    1. Advertising

  3. Guest

    On Feb 19, 3:11 pm, Wojtek <> wrote:
    > wrote :
    >
    > > I am going to create a form that will have about 3 pages of inputs in
    > > one form.
    > > The first and second page will have continue button and the final page
    > > (3rd page) will have the submit (into database) button.

    >
    > > What is the best way to forward the form inputs from each page so all
    > > will be submitted?

    >
    > Create an object which will hold all the form inputs, and store that
    > object in the user's session. You can also store state, so you know if
    > the user clicks on the Back button, or tries to go to page two without
    > first going to page one.
    >
    > --
    > Wojtek :)


    Thanks, I assume I can create an object using JavaBean class where I
    will take all the fields (via getter and setter methods) and use a
    special method to grab all the fields into one object. Then call that
    special method in my Servlet?
     
    , Feb 20, 2008
    #3
  4. Lew Guest

    wrote:
    > I assume I can create an object using JavaBean class where I
    > will take all the fields (via getter and setter methods) and use a
    > special method to grab all the fields into one object. Then call that
    > special method in my Servlet?


    That's one way, although you don't really need any method more special than
    doPost(), unless things get large enough to refactor.

    You could also, for example, use the ServletRequest method getParameterMap()
    and work directly off the Map of parameters:
    <http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameterMap()>

    This has the advantage of grabbing all the parameters in one fell swoop, and
    the disadvantage of leaving all the parameter values as unvalidated Strings
    packaged in the String [] values of the Map.

    --
    Lew
     
    Lew, Feb 20, 2008
    #4
  5. Wojtek Guest

    fr-) wrote :
    > On Feb 19, 3:11 pm, Wojtek <> wrote:
    >> wrote :
    >>
    >>> I am going to create a form that will have about 3 pages of inputs in
    >>> one form.
    >>> The first and second page will have continue button and the final page
    >>> (3rd page) will have the submit (into database) button.
    >>> What is the best way to forward the form inputs from each page so all
    >>> will be submitted?

    >>
    >> Create an object which will hold all the form inputs, and store that
    >> object in the user's session. You can also store state, so you know if
    >> the user clicks on the Back button, or tries to go to page two without
    >> first going to page one.
    >>
    >> --
    >> Wojtek :)

    >
    > Thanks, I assume I can create an object using JavaBean class where I
    > will take all the fields (via getter and setter methods) and use a
    > special method to grab all the fields into one object. Then call that
    > special method in my Servlet?


    Well, you CAN use a bean, but a simple class will also do. Extracting
    form fields from the request is not all that difficult, and it lets you
    condition the information, for things like valid input, ie: all numbers
    for a numeric value, and within bounds, so that month value is within
    1 and 12 inclusive.

    NEVER assume that the user is kind enough to always enter valid values
    :)

    --
    Wojtek :)
     
    Wojtek, Feb 20, 2008
    #5
  6. Guest

    Thanks Lew and Wojtek!
     
    , Feb 20, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Lozzi

    User Controls not keeping property values

    David Lozzi, Dec 19, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    1,402
    David Lozzi
    Dec 20, 2005
  2. =?Utf-8?B?QmFkaXM=?=

    Keeping Values of a Form

    =?Utf-8?B?QmFkaXM=?=, Dec 5, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    298
    Eliyahu Goldin
    Dec 5, 2006
  3. Replies:
    1
    Views:
    765
  4. tshad
    Replies:
    0
    Views:
    344
    tshad
    Sep 13, 2008
  5. Roy Smith
    Replies:
    11
    Views:
    519
    Dan Stromberg
    Dec 31, 2010
Loading...

Share This Page