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?
public interface ServletContext. Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file. There is one context per "web application" per Java Virtual Machine.
The pageContext object is used to represent the entire JSP page. This object is intended as a means to access information about the page while avoiding most of the implementation details. This object stores references to the request and response objects for each request.
scope="session" : The object is accessible from any JSP page that is sharing the same HTTP session as the JSP page that created the object. A session-scope object is stored in the implicit session object.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With