This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting and sending variables

 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to keep the 3 Tier architecture. I'd like to have a JSP page for presentation with a value. I then pass the value of that variable to the servlet using the request.getParameter method. I perform some operations with the variable. Now when I redirect from my servlet to a new JSP, how can I get the value of that variable?
 
Kaustubh Patil
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever u pass a form fiels as a part of request its just for the request. You can get it only in the servlet. When you invoke another jsp or servlet from it.. the values are no more part of the request.
There are two ways to get the values on the next page also..
1. put it in the session. But one should be very careful about putting anything in to session. because if the session gets too heavy it hampers the performance of the application.
2. another way is that when invoking a jsp/servlet from the servlet put the value as a hidden field or as a wuery string.
hope it helps..
-kaustubh.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris, instead of redirecting, you can use the forward method of the requestDispatcher. In this case the rquest object is available to the JSP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic