Is servlet essentially different from JSP?

Source: Internet
Author: User

Sun first proposed the servlet system, which allows Java programmers to develop Web applications based on B/S architecture, use the servlet class to encapsulate HTTP requests and responses in the standard Java class to implement various web application solutions.
With the development of a large number of B/S architecture programs, it is found that Servlet classes are very tedious to write, mainly focused on several issues: first, there are a lot of redundant code, these codes are identical or almost similar in each servlet class.
Second, Servlet developers are rarely proficient in the art. As a result, Servlet developers cannot easily achieve various page effects and rich styles. At this time, Sun borrowed Microsoft's ASP method, JSP (servlet 1.1) is officially proposed. After JSP is launched, Java programmers can add server code to static pages that have been designed by artists as ASP programmers do, a JSP Container automatically parses the JSP file and converts it to a servlet class (JSP to servlet compilation process) for the Web server to run. This greatly improves the work efficiency.
There is no essential difference between JSP and Servlet, because JSP still needs to be compiled into servlet class at the end of the submission. JSP is an extension of Servlet technology and is based on Java Servlet technology. It is essentially a simple servlet method, with more emphasis on the external expression of the application. After JSP compilation, it is "servlet-like ".
The two have the biggest difference, that is, when you use JSP to write an error, it is not easy to troubleshoot it. But writing it into servlet is much more convenient, just like writing a Java class.

When both ASP + COM and JSP + bean adopt component technology, all components are compiled first, resident in the memory, and then run quickly. Therefore, the speed advantage of the servlet/jsp that is often blown out after the memory is compiled first is no longer needed.
On the contrary, ASP + COM + IIS + nt should be closely integrated, and there should be a great speed advantage. In addition, ASP + COM + IIS + nt development efficiency is very high, although there are many bugs.

JSP's responsibility: extract data from the database and display all the message information (using a small amount of, simple logic processing: loop), display the page for signing the message (almost all are html ).
Servlet's responsibility: accept the data of the bidding form submitted on the logon message page for data verification. If the data is correct, store the data to the database and return the display page of the message. If the data is incorrect, after an error message is displayed, return to the logon message page. As you can see, this is called logical processing. You can also implement these functions in JSP, but with Servlet, the efficiency and security are much higher, making the JSP page very concise and clear.
The duty of JavaBean: in fact, the general message board does not need to use JavaBean, but here, in order to make you understand, it is far-fetched to use the JavaBean. The so-called Javabean is a very simple Java class. For example, all commodities in the online marketplace are commodities, and all posts in the Forum are post classes. Here, all messages on the message board are a message class. Each class has its specific attributes and methods. For the message class, its attributes include the topic, content, date, and message owner. You can add, delete, or modify a message. The use of JavaBean mainly aims to allow JSP programming to adapt to the habits of Java programmers and directly operate classes and instances, rather than directly operating databases.

Javabean is a class that defines a series of get <Name> and set <Name> methods.

Differences between JavaBean and class libraries:
(1) Not all useful modules must be converted to Bean. Bean, which can be used for visualized operations to achieve some results.
(2) A class library is an effective operation that provides function operations to programmers, but it cannot benefit from visual operations.
(3) For example, it is better to provide APIs for JDBC database access as a class library than as a bean, because the core of JDBC is to use a programmable API, it is not directly visible in visual operations. however, writing a library to access bean at the top layer of JDBC makes sense. for example, you can write a customized "select" bean to help you form a query statement. When the program is running, run the query statement using JDBC and display the result set.

EJB is Sun's server component model. Its greatest use is to deploy distributed applications, similar to Microsoft's. COM technology. With the advantages of cross-platform Java, distributed systems deployed with EJB technology can be not limited to specific platforms. EJB (Enterprise JavaBean) is a part of J2EE and defines a standard for developing multiple enterprise applications based on components. It features network service support and core development tools (sdks ).
 

 

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.