• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Pass a Variable from JSP via JSP to an Action Servlet

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic