Solved

How to pass form field values between JSP pages?

Posted on 2004-08-24
8
360 Views
Last Modified: 2011-09-20
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.
0
Comment
Question by:g118481
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 32

Expert Comment

by:ldbkutty
ID: 11884480
Use POST method in your FORM tag.
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 11884506
<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>
0
 
LVL 32

Expert Comment

by:ldbkutty
ID: 11884532
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:g118481
ID: 11884922
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.
0
 
LVL 6

Expert Comment

by:dorothy2
ID: 11885069
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
0
 
LVL 1

Author Comment

by:g118481
ID: 11885112
Dorothy,

That sounds like a good option.
Would you have an example to share?
0
 
LVL 11

Accepted Solution

by:
sompol_kiatkamolchai earned 50 total points
ID: 11888868
To share variable in session scope you can bind your value by

session.setAttribute("var1", someObject);

the above can be used in jsp page, if you want to do in Servlet the session variable need to get from request object.

HttpSession session = request.getSession();
session.setAttribute("var1", someObject);

and then var1 in session object will be available until session expired or IE browser is closed by client.
0
 
LVL 7

Expert Comment

by:a1programmer
ID: 11896348
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java cyclic graphs 15 220
attribute vs parameter and setter vs add method 17 94
maven set up 2 190
how to debug htl and js pages 8 57
This article was originally published on Monitis Blog, you can check it  here . If you have responsibility for software in production, I bet you’d like to know more about it. I don’t mean that you’d like an extra peek into the bowels of the sour…
Building a cohesive image for your brand is vital to making an impression on consumers. When the economy is tough, brands do better than unbranded  products. This can have a huge impact on your long-term profits, as the economy goes up and down.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question