Simple JSP Tutorial: component-centric development platform

Source: Internet
Author: User

JSP is an expression layer technology built on the Java servlets model. It makes HTML compilation easier. Like SSJS, it also allows you to mix static HTML content with server scripts to generate dynamic output. JSP uses Java as the default scripting language. However, just as ASP can use other languages, such as JavaScript and VBScript, JSP standards can also be used in other languages. Although JSP and Java have better compatibility and robustness than those based on simple language scripting platforms such as JavaScript and VBScript, it is more difficult to learn Java than a simple scripting language.

To take into account both advantages-a robust web application platform and an easy-to-use language tool-JSP provides a large number of server-side Tag ), this allows developers to complete most dynamic content operations without writing Java code. Developers who are only familiar with script writing, or even HTML designers, can use JSP tags to generate simple output without learning Java. Advanced script writers or Java programmers can also use these tags. To perform more advanced operations on JSP pages, they can use the complete Java language. In this concise JSP tutorial, you will learn about the origins and advantages of JSP.

The Page is outdated, and Component is amazing.

To understand how JSP can combine infinite power to easily achieve the magic effect, you must first understand the differences between "component-centric web development" and "Page-centric web development.

Both SSJS and ASP were launched a few years ago. At that time, the network was still very young, no one knows what a better solution is to pile all business, data, and expression logic into the original webpage. This page-centered model is easy to learn and rapidly develops. However, over time, it is recognized that this method is not suitable for building large, scalable web applications. The expression logic written in the script environment is locked in the page and can be reused only by cutting and pasting. The expression logic is usually mixed with the business and data logic, so that when programmers try to change the appearance of an application and do not want to break the business logic closely integrated with it, application maintenance is as difficult as walking on an eggshell. In fact, the application of reusable components in enterprises has been very mature, and no one is willing to rewrite those logics for their applications. HTML and graphic designers handed over their design implementation work to web writers, making them have to do more-often hand-written, there is no proper tool to combine server scripts with HTML content. In short, with the increasing complexity of web applications, the limitations of page-centric development methods become obvious.

At the same time, people have been looking for better ways to build web applications, and components are becoming increasingly popular in the client-server field. JavaBeans and ActiveX are promoted by "Quick Application Development" RAD) tool publishers to Java and Windows application developers for rapid development of complex programs. These technologies allow experts in a certain field to write components for vertical applications in this field, and developers can use them directly without having to master specialized technologies in this field. For example, a Java programmer who compiles a ro mate habit chart does not need to know any knowledge about ro. He only needs to call LemmingsInLove JavaBeansJavaBeans, which is a Java-based component) he only needs to focus on how to make the software easier to use. It is only a matter of time before a component-centric programming method is introduced to the web application field on the server.

As a component-centric development platform, JSP emerged. Based on the business and data logic model of the JavaBeans and Enterprise JavaBeansEJB components, it provides a large number of labels and a script platform to display the content generated or returned by the JavaBeans on the HTML page. Due to the component-centric nature of JSP, it can be used by Java and non-Java developers. Non-Java developers can use the tag Tags of JSP to use the ANS ans created by advanced Java developers. Java developers can not only create and use JavaBeans, but also use the Java language in JSP pages to control the expression logic based on the underlying JavaBeans more precisely.

JSP request Model

Now let's take a look at how JSP processes HTTP requests. In the basic request model, a request is directly sent to the JSP page. JSP code controls the interaction with the JavaBeans component during logical processing, and displays the results on dynamically generated HTML pages that contain a mixture of Static HTML code.

Beans can be a JavaBeans or EJB component. In addition, a more complex request model can be seen as calling other JSP pages or Java servlets from the requested pages.

Inside View of JSP Engine Technology

The JSP Engine actually needs to convert JSP tags, Java code on JSP pages, and even static HTML content into large Java code. These code blocks are organized by the JSP Engine into Java Servlets invisible to users, and then the servlet automatically compiles them into Java bytecode. In this way, when a visitor requests a JSP page, if he does not know it, a pre-compiled servlet will actually complete all the work. Very concealed-and efficient. Because the servlet is compiled, the JSP code in the webpage does not need to be interpreted every time the page is requested. The JSP engine only needs to compile the servlet code once after it is modified. Then the compiled servlet can be executed. Because the JSP Engine automatically generates and compiles servlets without the need for programmers to compile code, JSP can provide you with efficient performance and the flexibility required for rapid development.

If you download the JSP reference implementation from Sun and use it to write an application, you will be able to see the. java and. class files generated by the JSP Engine. If you want to learn more about the generated code, you can open the. java file in a text editor to view the Java servlet code.

After reading this simple JSP tutorial, you may have a new understanding of JSP.

  1. Develop jsp http Server
  2. Rebuild Struts2 JSP pagination
  3. Three methods for displaying Chinese Characters in JSP Web programs
  4. Java JSP uses Google's Translate to develop APIs
  5. Detailed analysis of nine implicit JSP objects

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.