View Full Version : JSP access form data from different pages

11-17-2006, 08:34 PM
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"

<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">

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
<c:out value="${param.confirm_reg}" /> will display yes but
<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

11-18-2006, 12:31 AM
Why not store values in a session.

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

in your first page,

String name = "John Smith";

session.setAttribute( "userName", name );

in your second page

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

good luck.


11-18-2006, 03:16 PM

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