This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between page and request

 
Prasanna RamKumar
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between page and request scope
prasanna
 
Ajith George
Ranch Hand
Posts: 109
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
page - You can use the Bean within the JSP page with the
<jsp:useBean> element or any of the page's static include files, until the
page sends a response back to the client or forwards a request to another
file.

request - You can use the Bean from any JSP page processing the same
request, until a JSP page sends a response to the client or forwards the
request to another file. You can use the request object to access the Bean,
for example, request.getAttribute(beanInstanceName).



Basically, page and request scope both end when your JSP page finished
processing. So even if a FORM is sent to the client by JSP, when that FORM
is submitted it will be a new Request. I think the only difference between
page and request is if the bean persists between forward() calls.
 
Talha-bin -Shakir
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Page Scope is the smallest scope, and is a representation of the PageContext object for your JSP. Each JSP has it's own page scope, so objects in the page scope of one JSP are not accessible to other JSPs. This is sorta like making a private variable in Java.

Request scope is the next smallest scope, and is represented with the JSP's request object. All JSPs and servlets that share a request share the request scope. For example, if I have a JSP that forwards to another page, and that second page includes a third JSP page, then all three pages are in the same request, and can share objects through the request scope. A special note here, is the response.redirect(), will create a new request, unlike forwards and includes. Also note, a new request is made every time the user gets a new page, be it by clicking a link, a button, or some JavaScript call.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic