Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the correspondence between Servlet API and JSP internal objects?

Shulou Source: shulou.com Published: 2022-06-02 12:31:23 10月03日 Update

This article mainly introduces Servlet API and JSP internal object correspondence is what kind of, has a certain reference value, interested friends can refer to, I hope you read this article after a lot of gains, the following let Xiaobian with everyone to understand.

JSP provides eight internal objects, five of which correspond to seven objects in Servlet API, which makes it especially important for us to understand and use these seven objects in Servlet properly. The correspondence between these five JSP internal objects and objects in the Servlet API is:

Request objects correspond to: javax.servlet.http.HttpServletRequest and javax.servletRequest

Response objects correspond to: javax.servlet.http.HttpServletResponse and javax.servletResponse

◆session object corresponds to: javax.servlet.http.HttpSession

◆application object corresponds to: javax.servletContext

◆config object corresponds to: javax.servletConfig

javax.servlet.http.HttpServletRequest

This is an interface, and before we get to interfaces, let's review a rudimentary explanation of interfaces in Java: interfaces are syntactically similar to classes, but interfaces have no instances, and using interfaces simply specifies what classes must do rather than how. The HttpServletRequest interface is used to process an HTTP request for Servlet API information.

javax.servlet.ServletRequest

This is also an interface that defines an object generated by the Servlet engine through which the Servlet can obtain the data requested by the client. This object provides all the data including the names, values, and attributes of parameters and input streams by reading the data of the requester. javax.servlet.http.HttpServletRequest is just an extension of this interface, that is, all methods of this interface can also be used by javax.servlet.http.HttpServletRequest in Servlet API.

javax.servlet.http.HttpServletResponse interface

This interface is used to describe an HTTP response returned to the client.

javax.servlet.ServletResponse interface

This interface is used to define an object generated by the Servlet API through which the Servlet responds to client requests. The response should be a MIME entity, possibly an HTML page, image data, or other MIME format. The javax.servlet.http.HttpServletResponse interface is an extension of this interface.

javax.servlet.http.HttpSession interface

This interface is used to describe a session. As for what is a session, I think there is no need to say it here.

javax.servlet.ServletContext interface

This interface defines an environment object for a Servlet API. It can also be considered that this is information shared by multiple clients. The difference between it and session lies in the different application scope. Session only corresponds to one user.

javax.servlet.ServletConfig interface

This interface defines an object through which the Servlet Engine configures a Servlet API. Each ServletConfig object corresponds to a Servlet ***.

javax.servlet.http.Cookie class

This class describes a cookie, the role of cookies is actually very similar to the session, but the cookie is saved on the client side, and the session is saved on the server side.

Thank you for reading this article carefully. I hope that Xiaobian's "Servlet API and JSP internal object correspondence" will be helpful to everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

Tags: Interfaces objects customers data articles just client information engine format end this is different skilled similar important necessary that is that is value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Docker Shulou Information Apple MariaDB