Meaningless Drivel is fun!
The moose likes JSP and the fly likes difference between page and request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "difference between page and request" Watch "difference between page and request" New topic

difference between page and request

Prasanna RamKumar
Ranch Hand

Joined: Nov 30, 2005
Posts: 31
what is the difference between page and request scope
Ajith George
Ranch Hand

Joined: Dec 22, 2005
Posts: 109
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

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.

SCJP 1.4, Brainbench
LinkedIn - Blog
Talha-bin -Shakir
Ranch Hand

Joined: Jan 26, 2006
Posts: 32
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:
subject: difference between page and request
It's not a secret anymore!