Java EE 13 specification (4)-jsp

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

JSP full Name (Java Server page), also known as Java Server Pages. See if the JSP immediately think of the original learned ASP.

A. JSP and ASP comparison:

Both JSP (Java Server Page) and ASP (Active Server page) are both common Dynamic Web page technologies, which can also be embedded in HTML programs, but they are fundamentally different, and are compared mainly from the following aspects:
1.Web Server support: most common WEB servers such as Apache, Netscape, and Microsoft IIS support JSP pages, and only Microsoft's own Microsoft IIS and personal Web Server can support ASP.
2. Platform support: JSP has platform independence, as long as the general Java program can run platform, all support JSP program. The Windows platform can support ASP very well, but it is difficult for ASP to be ported to other platforms because of its dependence on the Win32 gradual model.
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 the further study of JSP, we found that JSP and servlet have this close connection. JSP, like a servlet, is executed on the server side. Usually returned to the client is an HTML text, so the client can browse as long as there is 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 access the application logic of resources that exist on the server through tags and scriptlets. JSP separates the Web page logic from the display of the web design, supports reusable component-based design, and makes the development of Web-based applications quick and easy. 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 eventually 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, the use of JSP only need to complete the programmer needs to output to the client's content, the JSP java script How to mosaic into a class, by the JSP container to complete. 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.HTML Client code:

2. The next job is to work with JSP itself, and in Tomcat's work folder, the following Java and Response class file code is automatically generated:

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, compared with learning, but also slowly understand the truth of it. 

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.