The five advantages the JSP language has for developers

Source: Internet
Author: User
Tags expression html page

In Web application development, there are many dynamic page language technologies available, such as PHP, ASP, JSP, etc., in these dynamic page language, JSP by virtue of its own advantages to become one of the most favorite language developers. Here are some of the important reasons developers love JSP.

1.JSP is embedded in the HTML Java code, so in essence JSP program is a Java program, JSP program inherits all the advantages of Java. JSP programs have strict Java class library support.

2.JSP pages in the server will be the JSP compiler code called the corresponding servlet, so the advantages of Java Cross-platform, all JSP programs, without changes can be easily migrated to other operating system platform, which is not conceivable in other dynamic scripting languages.

3.JSP can use JavaBean for logical encapsulation, so that the logic function code can be reused, thus greatly improve the reusability of the system, colleagues also improve the development of the program efficiency.

4.JSP programs are easy to start with, and if you have the basics of HTML and Java, it's no difficulty learning JSP programs.

5. In the Java field, open source projects are growing, these open-source projects are the heart of the world's Java enthusiasts crystallization, in the JSP program can be very easy to use these open source tools. With the support of Open source project, JSP is not compared with other dynamic languages.

Developers from the love of Java extended to the love of JSP, colleagues JSP things in the system is the most important, but also the most basic part, if you want to experience the development efficiency and advantages of the EE, JSP will be a very effective way to get started.

The JSP compiler guidelines and instruction components have five types. After JSP1.0, most of the JSP is contained in a single tag that ends. The new JSP1.1 specification has been published and is also compatible with XML.

The compiler guidelines for the five types of JSPs are as follows:

1. Compiler guidelines

2. Predefined

3. Operational type

4. Program code

5. Annotations

Below we analyze a simple JSP page. You can create another directory in the JSWDK examples directory where the file name can be arbitrary, but the extension must be. jsp. As you can see from the code listing below, the JSP page has essentially the same structure as a few more Java code than a normal HTML page. Java code is added to the middle of the HTML code by means of symbols, and its main function is to generate and display a string from 0 to 9. At the front and back of this string are some text that is output through the HTML code.

 
  
  
  1. < html> < head>< title>jsp Page </title>
  2. GE language= "java"%> <%! String str= "0"; %> <% for (int i=1 i < i++) {str
  3. Strstr = str + i; %> JSP output before.
  4. < p> <%= str%> < p> jsp output.
  5. </body>

The first is the JSP directive. It describes the basic information about the page, such as the language used, whether the session state is maintained, whether buffering is used, and so on. JSP directives are terminated by. In this case, the instruction "" simply defines the Java language used in this example (Currently, Java is the only supported language in the JSP specification).

The next is the JSP declaration. A JSP declaration can be viewed as a place to define variables and methods at this level of class. JSP declaration by end. As in this example, "" defines a string variable. After each declaration, you must have a semicolon, just as you would declare a member variable in a normal Java class.

The code block between is the Java code that describes the processing logic of the JSP page, as shown in the For loop in this example.

Finally, the code in between is called a JSP expression, as shown in this example. A JSP expression provides a simple way to embed a JSP-generated value into an HTML page.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.