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
Solved

How to pass form field values between JSP pages?

Posted on 2004-08-24
8
359 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven webservice projet error 6 80
getting param value 7 58
maven j2ee examles 2 60
mask rule in struts validation.xml 5 94
Giving access to ESXi shell console is always an issue for IT departments to other Teams, or Projects. We need to find a way so that teams can use ESXTOP for their POCs, or tests without giving them the access to ESXi host shell console with a root …
Read about why it is more lucrative for an IT company to participate in government projects.

837 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