• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pass a Variable from JSP via JSP to an Action Servlet

JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!