Solved

How to pass form field values between JSP pages?

Posted on 2004-08-24
8
361 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

The conference as a whole was very interesting, although if one has to make a choice between this one and some others, you may want to check out the others.  This conference is aimed mainly at government agencies.  So it addresses the various compli…
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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