Solved

Values in variables passed between jsp pages seem to be lost

Posted on 2009-03-30
9
299 Views
Last Modified: 2012-05-06
I am trying to pass variables (or parameters) between jsp pages. I am using a combination of request.getparameter to do this. In main page, I set value of variable either through input or via assignment from hidden input field on screen. On the next screen, I use request.getparameter on same parameter name.

For some reason, I don't see the values get passed back and forth.

What gives?
0
Comment
Question by:bluegreen288
[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
  • 6
  • 3
9 Comments
 
LVL 5

Expert Comment

by:TheVeee
ID: 24019269
Yeh that should be really easy, might be a type, can you cut and paste your code for jsp and and servlet to let us look at it...
0
 
LVL 5

Expert Comment

by:TheVeee
ID: 24019411
Heres a tutorial on how to do it if you dont want to post your code:

http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/
0
 

Author Comment

by:bluegreen288
ID: 24031704
Lead was actually helpful. It eventually pointed me to the solution.
0
Technology Partners: 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 5

Expert Comment

by:TheVeee
ID: 24032116
Cool, just post what you found and next person looking for a solution will be able to use it...Glad to help!
0
 
LVL 5

Expert Comment

by:TheVeee
ID: 24043675
So what did you find?  You need more help?
0
 

Author Comment

by:bluegreen288
ID: 24051933
The website gave me a good insight on parameter passing. The variables I was using for parameter passing were local to their respective scriplets so I was losing value (because the context of the variables were local).  

It also led me to the book 'More Servlets and JavaServer Pages' by Marty Hall.

I have a question though. How do I keep a radio button checked when control changes to another jsp page then back?
0
 
LVL 5

Expert Comment

by:TheVeee
ID: 24052068
Dont know your overall approach, but heres how I would do that...

1.  ON form that has the check box would include a form bean and within add another attribute it for field

2.  Next would add javascript to check for that SAME initial page and if field in been is null or empty, leave check box unchecked.

3.  Next on the action after they click submit, grab the form bean passed to it (which will be the form bean you put in step 1), and then html check box is checked.  If checked, would now set value to attribute created in step 1 in form bean, persisist it to the database if  needed,  Then if a error occurred either before I persisted or after, would then loop back to the initial form and then the javascript would kick in to see hey, the form attribute in step 1 is now not null or blank, and the html would mark it checked.
0
 

Author Comment

by:bluegreen288
ID: 24055852
Thanks so much. It helps.
0
 
LVL 5

Accepted Solution

by:
TheVeee earned 250 total points
ID: 24059528
Hey also was looking thru some stuff, heres a great tutorial for you and also look at booklist.jsp.   Shows exactly what I was explaining...

http://www.laliluna.de/first-java-servlets-jsp-tutorial.html

If this answers your questions could you accept the answer so I get the points?
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

751 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