What are the different scopes in JSP?
Answered
What are the different scopes in JSP?
Best answer
Objects in a JSP, whether explicit or implicit, are accessible within a particular scope. In the case of explicit objects, such as a JavaBean instance created in a <jsp:useBean> action statement, you can explicitly set the scope using the attribute scope=”scopevalue”.
There are four scopes available in JSP:
- “page” scope – The object is accessible only from within the JSP page where it was created.
- “request” scope – The object is accessible from any JSP page servicing the same HTTP request that is serviced by the JSP page that created the object.
- “session” scope – The object is accessible from any JSP page sharing the same HTTP session as the JSP page that created the object.
- “application” scope – The object is accessible from any JSP page used in the same Web application (within any single Java virtual machine) as the JSP page that created the object.