• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing variables jsp and servlet

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a jsp called customer.jsp that calls a action class called CustomerAction. This Action insert information from the jsp into a database. One of the fields for example first name I would like to display in the next jsp that follows. I have done this with request.setAttribute("first", firstname); then I can display it on the next jsp using logic resent and bean:write. Question is how can I get it to the second action class?

I'm using stuts
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could pass the required field as a hidden parameter which you could then retrieve in the next action class.
 
Zach Young
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any examples on how this would be done?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<form name="myForm" id="myForm" method="post" action="/myNextActionServlet">
<input type="hidden" name="firstName" id="firstName" value="${ first }" />
<input type="submit" name="submit" id="submit" value="Next Step ->" />
</form>

In your servlet you would then get the value with

String firstName = request.getParameter("firstName");
[ November 23, 2005: Message edited by: Than Long ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic