Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing parameters from servlet to jsp

 
ramanuja varun
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we pass parameters from servlet to jsp without using attributes
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why? Scoped variables (what you called attributes) are the correct means to carry data from a servlet to a forwarded JSP.
 
ramanuja varun
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i just wanted to know if there is a way to pass parameters from servlet to jsp without using the attributes.Please let me know if the answer is yes and do explain with an example
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say "parameters" are you talking specifically about request parameters (as submitted by a form) or using the term generically to mean "data"?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ramanuja varun:
... without using the attributes.
It's also a good idea to use correct terminology. The correct term is "scoped variables", not "attributes".
 
ramanuja varun
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes sir, i am talking about request parameters.Is there a way?
[ September 16, 2008: Message edited by: ramanuja varun ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Request parameters will automatically be carried along on the request and you don't have to do a single thing.

That assumes, of course, that you are forwarding the request from the servlet to the JSP. If you are performing a redirect, a new request is generated and the parameters will be lost.

Customarily, if these data values need to be kept around, scoped variables in session scope are used.

But other ways could be to store them in cookies, write them to a database, write them to files, and so on.

What's your beef with scoped variables?
[ September 16, 2008: Message edited by: Bear Bibeault ]
 
ramanuja varun
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir Imagine i have a form where in i enter the username and password.Now i have passed them on to the servlet.Further I would like to know is there a way to pass the same request parameters from the servlet to another jsp without using set and getAttributes.I hope the scenario is clear now.
Thanks
[ September 16, 2008: Message edited by: ramanuja varun ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just like I said. It depends how you are traversing from the servlet to the JSP.
 
ramanuja varun
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir can you please explain with a n example how to use the cookies or session to perform the task
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic