HelloWorld program instance for getting started with JSP, helloworld for getting started with jsp

Source: Internet
Author: User

HelloWorld program instance for getting started with JSP, helloworld for getting started with jsp

This article describes the HelloWorld program for getting started with JSP. We will share this with you for your reference. The details are as follows:

Here is the first JSP-HelloWorld! Every "First Love" is mysterious, revealing the secret of JSP!

JSP is also a j2ee specification.

JSP (java service Page) is a dynamic web Page Technical Standard promoted by sun and participated by many companies.

The difference between JSP and html is that java code and JSP tag are embedded in the webpage to form a. jsp file.

Web applications developed by JSP are cross-platform. They can run both on Linux and other operating systems.

After learning Servlet and later learning JSP, it is said that because we use Servlet, too much html code is too cumbersome when we return the page to the client, it is also cumbersome to re-compile the servlet code and restart tomcat to re-Send it to the client. If we beautify the returned page, as a result, sun has been fully considered for programmers.

So JSP came into being.

What about the JSP running mechanism? We can write a HelloWorld. jsp file and start the tomcat server to run successfully. But how can this process be implemented? What is the relationship between JSP and Servlet? What is the relationship between JSP and ASP? Next we will discuss it one by one.

The first. jsp file:

How is a JSP page implemented? Mechanism?

In fact, when you request a JSP page through http, Tomcat will first compile JSP into Servlet and then execute Servlet.

The running process is described in detail:

1. First, the web Client sends a URL request to Tomcat. The server obtains the request and analyzes the request string. If the suffix is A. jsp file, Tomcat calls JspServlet for processing. JspServlet is
2. If the JSP file is called for the first time, it will be compiled into a servlet. If jsp is not called for the first time, it will not be compiled. The Jsp file is compiled only once without modification.
3. Tomcat calls the service () method to compile the jsp file and create a. java and. class file. The java file inherits from the parent class HttpJspBase class.

4. Create the HttpServletRequest class and HttpServletResponse class
5. Call. java to inherit the HttpJspBase class method service (request, response) of the parent class)
6. Call the jspService (request, reponse) method in the service method to render the html and return it to the client.

What is the relationship between JSP and Servlet?

The first time I came into contact with JSP and Servlet, I have already said that JSP appears after Servlet. The running mechanism of JSP is also quite familiar. In fact, JSP is a Servlet, but some repetitive tasks let Tomcat do it. JSP makes up for the shortcomings of Servlet and is more user-friendly.

Differences:

Servlet is fully composed of java code and is good at Process Control and transaction processing.
JSP consists of HTML code and JSP tags, allowing you to easily write dynamic web pages.
Therefore, servlet is used to control business processes, while JSP is used to generate dynamic web pages.
JSP is equivalent to a file with the extension. jsp that can be combined by JAVA and Html.
JSP focuses on views. Sevlet is mainly used for control logic.

I hope this article will help you with jsp program design.

Articles you may be interested in:
  • Getting started with JSP custom tags
  • JSP classic learning notes (including various common syntaxes for beginners)
  • General JSP page jsp entry-level article
  • Jsp Hibernate getting started tutorial
  • JSP Quick Start
  • Several summary of JSP entry knowledge
  • Introduction to JSP development (1) -- install your machine to use JSP
  • Introduction to JSP development (5) -- Other JSP-related resources
  • Introduction to JSP development (IV)-Internal JSP objects
  • Introduction to JSP development (iii) -- JSP and JavaBean
  • Introduction to JSP development (II)-Basic Principles of JSP syntax
  • JSP development

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.