Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report