What is a JSP Context?
Asked Answered
M

2

9

I was wondering what exactly this java object is and what its main purpose is. I have looked java documentation, but that confuses me more :(.

Does it have any relation scopes such as session, request, application?

Mouthy answered 11/12, 2012 at 10:17 Comment(1)
Look at docs.oracle.com/javaee/1.4/api/javax/servlet/jsp/… But, did you really mean to ask about pageContext ?Mikvah
C
13

The JspContext

enter image description here

enter image description here

enter image description here

The JspContext is confusing, because it doesn't seem to do anything that the ServletContext can't do. You're right, it doesn't. You can live without the JspContext. The implicit variables are there at your disposal.

The primary benefit lies in the fact that the JSP technology is not necessarily bound to Java. Yes. You heard that correctly, JSPs are positioned to be cross-platform compatible.

Quoting the API:

JspContext serves as the base class for the PageContext class and abstracts all information that is not specific to servlets. This allows for Simple Tag Extensions to be used outside of the context of a request/response Servlet.

This abstraction allows a JSP to gather information about its environment (request, session and application scope) in a platform-neutral manner.

Cullan answered 28/6, 2013 at 17:2 Comment(0)
T
-3

JSP Context Object = Application context = ServletContext.

The scope is Application.

Hope this helps.

Theriot answered 11/12, 2012 at 10:26 Comment(1)
@BaluC May be I understood the question wrong. Is it not about the implicit object "application" in JSP. I meant to tell "application" implicit object is equal to Servlet Context. "javax.servlet.jsp.JspContext" object is not "ServletContext". Apologies for the confusion. Thank you BalaTheriot

© 2022 - 2024 — McMap. All rights reserved.