Java Bean and Servlet in JSP

Source: Internet
Author: User

In the past, I was not familiar with Java Development. I always thought that the JavaBean and Servlet are amazing, strange, and complicated. Now I have read a very basic JSP book, I have finally understood them.

Javabean is a Java class, except that it has the getxxx () and setxxx () methods, and. the get/set in net is similar, or it must be a public class with a non-argument constructor. In JSP development, it can be said to process some logic, such as computing, and the JSP page uses <JSP: usebean...> this label references this JavaBean class and displays the processing result and some information on the JSP page. It can be said that the background and foreground are basically separated.

Servlet is not specifically developed for HTTP, but it seems that it is only used here. It mainly applies the httpservlet class. Doget ()/doput ()/dopost ()... Wait for the doxxx method, and there is a service () method. These functions have only two parameters, one of which is httpservletrequest and httpservletresponse, reques is generated when the web server responds to the HTTP request of the browser and closes the request information in httpservletrequest. It also creates an httpservletresponse object and provides the servlet with the response information.

The Service () method has been implemented in httpservlet. It calls different doxxx () Methods Based on Different HTTP requests. At the same time, we do not directly call the doxxx () method, generally, we only need to override the doxxx () method. Httpservlet then automatically calls the Service () method and calls the doxxx () method by itself through the Service () method. In programming, we mainly cover the doget () and deput () methods.

The most important thing here is that the Web server encapsulates the client request information to httpservletrequest and creates httpservletresponse. Then we can get the corresponding request information and output the corresponding response.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.