Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing parameters in jsp

 
varun bihani
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 methods for passing parameter among various JSP's.
First is by use of hidden input type in the forms.
Second one is use of beans(setter and getter methods)
The problem with beans is these values expires after certain time..
I want to know which method is better....
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Varun
I assume you are talking about passing parameters from one jsp to another, correct? Yes, you can it with values on a form (either hidden or visible) and with a bean (assuming it is scoped as anything other than page). Also, dont forget about the Session and application objects too!! They can be real handy for passing info that you might not neccesarily need to manipulat with a bean but want to have on hand to use. A good one would be the persons name so you could personalize each page, or an id retrieved from a DB, so you dont have to get it each time you need it.
As far as which way is better than any other way it would all depend on what it is you need the piece of data to do, where you get the initial value from (user, DB, calculated), and how long you need it to be around.
Hope that helps a little bit
 
perry arora
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the jsp'd are in the same context
Use the application object(ServletContext) to store the values as name/value pairs
and can access it across any no of jsp in the application.
I agree that it depends on wat u wanna do!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic