• Post Reply Bookmark Topic Watch Topic
  • New Topic

pass via request or session object?

 
Phil Chuang
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the strengths/weaknesses behind either way of passing data back to the JSP?
1) request.setAttribute() then forward
2) session.setAttribute() then forward or redirect
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In what context? It's a bit simplistic, but you use the request for request based data so that it only exists for the current request/response, and you use the session for data that is used for the life of the session.
Dave
 
Scott Duncan
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words, if you need to use an object once, use a request object. For use several times put it in the session but be careful. Putting too many objects in the session can cause performance issues.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!