File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request vs. pageContext

 
Egil Poma
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the difference on putting a variable in request (request.setAttribute) vs. putting it in pageContext (pageContext.setAttribute)?

Variables in both scopes seems to live only for a single page view. So is there a difference?
 
ramesh kumar
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if we add variables to PageContext we can use them directly,if add them to request object we need to use getAttribute() method to get value
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ramesh kumar:
if we add variables to PageContext we can use them directly


I have no idea what is meant by this. Scoped variables in page scope are accessed in the same manner as in any other scope.

The difference is in the scope of the variables (where they can be accessed from) and in their life span.

Page-scoped variables are only available in the current page; not included pages, not forwarded pages. Request-scoped variables are available to every resource that participates in the creation of the response. They are most often used to pass data from a servlet controller to its view JSP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic