Solved

How to pass form field values between JSP pages?

Posted on 2004-08-24
8
350 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
unit test DAO layer 1 133
immutable object concept 5 105
authenticate preemptively soap ui option 3 109
AlarmClock Challenge 35 145
In  today’s increasingly digital world, managed service providers (MSPs) fight for their customers’ attention, looking for ways to make them stay and purchase more services. One way to encourage that behavior is to develop a dependable brand of prod…
Find out what the Office 365 disclaimer function is, why you would use it and its limited ability to create Office 365 signatures.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now