File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Pass a Variable from JSP via JSP to an Action Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Pass a Variable from JSP via JSP to an Action Servlet" Watch "Pass a Variable from JSP via JSP to an Action Servlet" New topic
Author

Pass a Variable from JSP via JSP to an Action Servlet

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
I am using the Struts framework.

I have the value of a variable defined in JSP#1 (JSP#1 is not a form):

All the variables, which are defined in JSP#1, are forwarded to JSP#2.

JSP#2 is a form. But, the variable 'id' is not used in JSP#2.

JSP#2 has a submit button and then, an action servlet takes over the control. All the text fields in JSP#2 together with the variable 'id' are forwarded to this action servlet.

I have two questions:

1. I should put this variable 'id' in the request scope or the session scope. Currently, it is in the session scope.

2. How to retrieve the value of this variable 'id' in the action servlet? (I do not want to print the value out. I want to retrieve the value and store it in a database.)

session.getAttribute( "id" ); // returns an object. 'id' should be an integer
[ July 01, 2004: Message edited by: JiaPei Jen ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pass a Variable from JSP via JSP to an Action Servlet