Java Web Learning (6): Understanding JSP

Source: Internet
Author: User
Tags microsoft iis support microsoft iis

Introduction to a JSP

The full name of the JSP is Java Server Pages, the Chinese name is the Java Servers page, it is simply a simplified servlet design, it is by the sun

Microsystems company advocates, many companies involved in the establishment of a dynamic Web technology standards. JSP technology is a bit like ASP technology, it is in the traditional

Web page HTML (a subset of standard generic Markup Language) files (*.htm,*.html) that insert Java program segments (scriptlet) and JSP tags (tag) to form a JSP

file with the suffix name (*.jsp). JSP is a dynamic Web technology standard is also Java EE standard. Web applications developed with JSP are cross-platform and can

Runs under Linux, and can also run on other operating systems.

It implements the Java extension in the HTM syntax (in <%%> form). JSP, like a servlet, is executed on the server side. Usually returned to the customer

End is an HTML text, so the client can browse as long as it has a browser.

JSP technology uses the Java programming language to write tags and scriptlets of class XML to encapsulate the processing logic that produces dynamic Web pages. Web pages can also be through tags

and scriptlets access to the application logic of resources that exist on the server side. JSP separates the Web page logic from the display of the web design, and supports reusable component-based

Design makes it quick and easy to develop web-based applications. JSP is a dynamic page technology, its main purpose is to represent the logic from

Out of the servlet.

Java servlet is the technical foundation of JSP, and the development of a large Web application requires Java servlet and JSP mates to complete. JSP Tool

Java technology is easy to use, fully object-oriented, platform-independent and safe and reliable, mainly for the internet all the characteristics.

JSP compiled is the servlet, the two are essentially the same. JSP emphasizes on the page display, the servlet is biased to the business logic processing.

The JSP is the extension of the servlet, and the servlet technology has appeared before the JSP. The servlet uses the output stream to dynamically generate HTML pages,

Includes each HTML tag and every content that appears in the HTML page.

JSP inserts Java code into a standard HTML page, and its static parts do not need to be programmed by Java, only those that require reading from the database and

Java Script control is used when generating information dynamically based on the program. In fact, JSP is a special form of servlet, and each JSP page is a

The servlet instance--jsp page is compiled by the system into Servlet,servlet and is then responsible for responding to user requests. JSP is also a simplification of the servlet, using

JSP, the servlet is actually used, because each JSP page in the Web App generates the corresponding servlet by the servlet container. For Tomcat and

, the servlet generated by the JSP page is placed under the Web application corresponding to the work path.

Two advantages and disadvantages of JSP technology (1) Strong JSP technology

1) Write once, run everywhere.

Java is better than PHP at this point, and the code does not have to make any changes other than the system.

2) Multi-platform support for the system.

can be developed in virtually any environment on all platforms and deployed in any environment, in any environment extension. Compared to Asp/php's

Limitations are present and easy to see.

3) Strong scalability.

you can run servlet/jsp from only a small jar file, to cluster and load balancing by multiple servers, to more than one application.

Processing, message processing, a single server to countless servers, Java shows a huge vitality.

4) diverse and powerful development tools support.

This is like ASP, Java already has a lot of very good development tools, and many can for free, and many of them are

the operation of Lee in under multiple platforms.

5) Support server-side components.

Web applications require powerful server-side components to support, and developers need to design for complex features with other tools components for Web pages to tune

To enhance the system performance. JSP can use mature JavaBeans components to achieve complex business functions.

(2) Disadvantages of JSP

1) As with ASP, some of Java's advantages are its deadly problem. Because of the ability to cross-platform, for extreme scalability,

So the complexity of the product is greatly increased.

2) The speed of Java is done with the class resident memory, so it is in some cases used in memory than the number of users is indeed "the most

Low performance price ratio. "

Three JSP technical methods

In order to quickly and easily develop the dynamic Web site, JSP in the following aspects of the improvement, making it a rapid establishment of cross-platform dynamic site of the first

Options.

The most significant is the JSP technology that separates the generation and display of content.

With JSP technology, Web page developers can use HTML or XML tags to design and format the final page, using JSP identifiers or small

The script generates dynamic content on the page (the content is changed according to the request, such as requesting account information or the price of a particular bottle of wine, etc.). Generate content

The logic is encapsulated in the identity and JavaBeans components, and bundled in the script, all scripts run on the server side. Because the core logic is encapsulated in

Identity and JavaBeans, so web managers and page designers are able to edit and use JSP pages without affecting the generation of content.

On the server side, the JSP engine interprets the JSP identity and script to generate the requested content (for example, by accessing the JavaBeans component, using the JDBC technology

Access to the database or include files) and send the results back to the browser as HTML (or XML) pages. This helps the author to protect itself from

To ensure full availability of any HTML-based web browser.

1) Reusable Components

Most JSP pages rely on reusable, cross-platform components (JavaBeans or Enterprise JavaBeans components) to execute the application process

The complex processing required by the sequence. Developers can share and Exchange components that perform common operations, or make these components available to more users and client groups

Used by the body. The component-based approach accelerates the overall development process and enables organizations to develop their existing skills and optimization results

Balance.

2) using the logo

Web page developers are not all programmers who are familiar with scripting languages. JSP technology encapsulates a number of features in an easy-to-use, JSP

Required for dynamic content generation in the relevant XML identity. Standard JSP identity enables access to and instantiation of JavaBeans components, set or retrieve groups

Properties, download applets, and perform features that are more difficult to encode and time-consuming than other methods.

3) adaptation platform

Almost all platforms support Java,jsp+javabeans to almost all platforms. Porting from one platform to another flat

Tables, JSPs, and JavaBeans are not even recompiled, because Java bytecode is standard and platform independent.

4) database connection

The technology of connecting database in Java is the Jdbc,java program connects with the database through the JDBC driver, executes the query, extracts the data and so on.

Sun also developed JDBC-ODBC Bridge, which uses the technology Java program to access databases with ODBC drivers, most of which

The system has ODBC drivers, so Java programs can access databases such as Oracle, Sybase, MS SQL Server, and MS Access.

In addition, JSP technology can be further expanded by developing the identity library. Third-party developers and other people can create their own identities for common functions

Library. This enables Web page developers to work with familiar tools and artifacts that perform specific functions like identities.

JSP technology can easily be integrated into a variety of application architectures to leverage existing tools and techniques and scale to distributed applications that support enterprise-class

In As part of the adoption of the Java Technology family and as part of Java 2 (Enterprise Architecture), JSP technology can support highly complex

Web-based applications. Because the built-in scripting language for JSP pages is Java-based, and all JSP pages are compiled into Java servlets,

So JSP pages have all the benefits of Java technology, including robust storage management and security. As part of the Java platform, JSP has Java programming

The language "write once, run Everywhere" feature.

Four-language comparison

(1) The difference from Servlets

Architecturally, JSP can be seen as being applied as an extension of the Java Servlet2.1 API from Servlets advanced refinement. Servlets and JSP are the most

It was developed by Sun Microsystems Company. Since the JSP1.2 version, JSP has been in Java Community Process (translated as:

Java Community Organization) development model. JSR-53 specifies the specifications for JSP 1.2 and servlet 2.4, and JSR-152 specifies the specification for JSP 2.0. 2006 on 5

month, the specification for JSP 2.1 is published in JSR-245 as part of the Java EE5.

(2) comparison with ASP

Both JSP (Java Server Page) and ASP (Active Server page) are both common Dynamic Web page technologies that can be embedded in HTML

program, but the two are fundamentally different, mainly from the following aspects of the comparison:

1) Web server support: most common Web servers such as Apache, Netscape, and Microsoft IIS support JSP pages, with only micro-

Microsoft IIS and personal Web server for the software itself can support ASP.

2) Platform support: JSP has platform independence, as long as the general Java program can run platform, all support JSP program. Windows platform

The ASP can be well supported, but the dependence of ASP on the gradual model based on WIN32 makes it difficult to transplant to other platforms.

3) component model: JSP is built on reusable, cross-platform components such as: JavaBeans, Enterprises JavaBeans, and user-defined

Libraries and other components, and ASP uses the Win32-based COM component model.

4) scripting language: JSP can use Java programming language or JavaScript as scripting language, while ASP uses VBScript or JScript as scripting

Statements were
5) Security: JSP uses the Java security model, while ASP uses the Windows NT security architecture.

6) connection to Access database: JSP uses JDBC to establish a connection to an Access database, while ASP uses data Active for an Access database

Objects

7) User-defined tags: jsp can be used to expand the user-defined tag library, and the ASP does not have a user-defined tag library, ASP is not extensible .

Java Web Learning (6): Understanding JSP

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.