Link to home
Start Free TrialLog in
Avatar of g118481
g118481

asked on

How to pass form field values between JSP pages?

I have a JSP form, and I need to pass all the form field values between two other pages.
And one of the form field values is a textarea field.

I don't think they can be passed in the URL, because of the length restriction.
So how can I do this.

An example would be appreciated.
Avatar of ldbkutty
ldbkutty
Flag of India image

Use POST method in your FORM tag.
Avatar of sompol_kiatkamolchai
<form name="form1" action="jsp2.jsp" method="post">
  <input type="text" name="field1">
  <input type="text" name="field2">
  <input type="text" name="field3">
  <input type="text" name="field4">
  <input type="text" name="field5">
...
  <input type="text" name="fieldn">
  <input type="submit">
</form>
Avatar of g118481
g118481

ASKER

I am sorry.
I didn't clarify my request enough.

I know all too well how to use POST for forms.
My issue is, that I need to pass the form values to two other JSP pages after the initial POST has been made by the form.

Example:

1.  my form post the field values to a select statement that checks table2
2.  I then need to pass those same form field values back to the form, or to another insert statement, depending on the results from table2.
I think your issue is that (1) you don't want to pass the form values in the url because of size restrictions; and (2) if you pass them via POST, the form values are "request" level so you lose them after you process the page after the post.

I believe the request object stores all the values in a HashMap. Why don't you create your own HashMap, and give it "session" access? Then you can access the form values, update them whenever you want, and delete the HashMap when it is  no longer needed.

Dorothy
Avatar of g118481

ASKER

Dorothy,

That sounds like a good option.
Would you have an example to share?
ASKER CERTIFIED SOLUTION
Avatar of sompol_kiatkamolchai
sompol_kiatkamolchai
Flag of Thailand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could also create a form to store the hidden values after the first post...  Then you could submit it to the other 2 pages using javascript.