Java EE 13 specification (4)-jsp

Source: Internet
Author: User
Tags microsoft iis

The JSP full name (Java Server page), also known as the JavaServer page. See if the JSP immediately think of the previous learning of the ASP.

I. The comparison between JSP and asp:

Both JSP (Java Server Page) and ASP (Active Server page) are both frequently used Dynamic Web page technology, but also can be embedded in the HTML program, but the two are fundamentally different, mainly from the following aspects of the comparison:
1.Webserver support: Most common webserver such as: Apache, Netscape, and Microsoft IIS all support JSP pages, only Microsoft's own Microsoft IIS and personal Web The server can support ASP.
2. Platform support: JSP has platform independence, only if the general Java program can execute platform, all support JSP program. The Windows platform is very good at supporting ASP, but ASP's dependence on the Win32 gradual model makes it difficult to migrate to other platforms.
3. Scripting language: JSP can use the Java programming language or JavaScript as the scripting language, while ASP uses VBScript or JScript as the scripting language.
4. Security: JSP uses the Java security model, while ASP uses the Windows NT security architecture.

In fact, with our in-depth study of JSP, we found that JSP and servlet have this close connection. JSP, like a servlet, runs on the server side. Usually returned to the client is an HTML text, so the client only need to have a browser to browse. 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 access the application logic of resources that exist on the server through tags and scriptlets. JSP separates Web page logic from the display of web design, supports reusable component-based design, and makes web-based applications fast and easy to develop. JSP (JavaServer pages) is a dynamic page technology whose main purpose is to separate the presentation logic from the servlet.

Two. The difference between JSP and servlet:

1. There are no built-in objects in the servlet, and the built-in objects in the original JSP must be generated by the HttpServletRequest object or by the HttpServletResponse object.
2. For static HTML tags, the servlet must use the page output stream Kerouac line output.

3. The JSP is finally compiled into a servlet, so the JSP is slower than the servlet. JSP is responsible for the foreground page display, servlet is responsible for business control.

In short, JSP is a simplification of the servlet, using JSP only need to complete the program ape needs to output to the client's content, as for the JSP Java script How to mosaic into a class, by the JSP container finished. The servlet is a complete Java class, and the service method of this class is used to generate a response to the client.

three. Simple Example

1.HTMLclient Code:

2. The job behind the JSP is to work on its own, and in Tomcat's work directory, it will voluntarily generate the following Java and Response class file code:

Package Org.apache.jsp;import javax.servlet.*;import javax.servlet.http.*;import javax.servlet.jsp.*;p ublic final Class Helloworld_aaa extends Org.apache.jasper.runtime.HttpJspBase implements  org.apache.jasper.runtime.JspSourceDependent {private static java.util.List _jspx_dependants;  Public Object getdependants () {return _jspx_dependants; } public void _jspservice (HttpServletRequest request, httpservletresponse response) throws Java.io.IOException, Se    rvletexception {jspfactory _jspxfactory = null;    PageContext pagecontext = null;    HttpSession session = NULL;    ServletContext application = null;    ServletConfig config = null;    JspWriter out = null;    Object page = this;    JspWriter _jspx_out = null;    PageContext _jspx_page_context = null;      try {_jspxfactory = Jspfactory.getdefaultfactory ();      Response.setcontenttype ("text/html");      PageContext = _jspxfactory.getpagecontext (this, request, response, NULL, True, 8192, true); _jspx_page_context = PageContext;      application = Pagecontext.getservletcontext ();      Config = Pagecontext.getservletconfig ();      Session = Pagecontext.getsession ();      out = Pagecontext.getout ();      _jspx_out = out;      Out.write (" JSP and ASP and servlet, the comparison of learning, but also slowly clear the truth. 

Java EE 13 specification (4)-jsp

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.