Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing variables jsp and servlet  RSS feed

 
Zach Young
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Any examples on how this would be done?
 
Caine Lai
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!