Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JSP access form data from different pages

    I have 4 JSP pages "register.jsp" -> "registervalidation.jsp" -> "confirm.jsp" -> "confirmval.jsp".

    In "register.jsp" i have a form "name = register", this gets sent to "registervalidation.jsp" for validation, if everything is ok its forwards to "confirm.jsp".

    In "confirm.jsp" i have another form "name = confirm" the user submits yes or no and form is sent to "confirmval.jsp" if yes

    form from "confirm.jsp"
    Code:
    <form action="confirmval.jsp" method="post" name="confirm">
    Yes <input name="confirm_reg" type="radio" value="yes">
    No  <input name="confirm_reg" type="radio" value="no" checked>
    <input name="submit" type="submit" value="Submit info">
    </form>
    I can access the "confirm form" values but not the "register form" values. I'm presuming this is because i've sent a new form.
    For example
    Code:
    <c:out value="${param.confirm_reg}"  />
    will display yes but
    Code:
    <c:out value="${param.firstname}"  /> //info from register form
    will not display anything

    My Question is how can I access the values of the register form in confirmval.jsp as i want to use these for an sql insert statement

    Let me know if you need anything clarified


    P.S i know i could just use a Java Bean but havent really covered them yet. Will use as a last resort

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    Why not store values in a session.

    That way you will have those values in every page.
    for example,

    in your first page,
    Code:
    String name = "John Smith";
    
    session.setAttribute( "userName", name );
    in your second page

    Code:
    Hello, <%= session.getAttribute( "userName" ) %> and welcome ......etc
    good luck.

    Ess

  • #3
    New Coder
    Join Date
    Mar 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks

    just used a load of
    Code:
    <c:set var />
    in the validation page if everything was valid and set the scope to session. worked a treat.


  •  

    Posting Permissions

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