• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

Values in variables passed between jsp pages seem to be lost

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
bluegreen288
Asked:
bluegreen288
  • 6
  • 3
1 Solution
 
TheVeeeCommented:
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
 
TheVeeeCommented:
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
 
bluegreen288Author Commented:
Lead was actually helpful. It eventually pointed me to the solution.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
TheVeeeCommented:
Cool, just post what you found and next person looking for a solution will be able to use it...Glad to help!
0
 
TheVeeeCommented:
So what did you find?  You need more help?
0
 
bluegreen288Author Commented:
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
 
TheVeeeCommented:
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
 
bluegreen288Author Commented:
Thanks so much. It helps.
0
 
TheVeeeCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now