L--jsp and Servlets

Source: Internet
Author: User

Brief introduction

There are two main techniques for developing Web applications in Java, namely Servlets and JSPs. A servlet is a Java program executed on the server side, and a program called a servlet container (which is actually a server) is responsible for executing Java programs. The JSP (Java Server page) is a page that is executed by the JSP container .

Difference

The most important difference between servlet and JSP is that the servlet is dominated by Java programs, the output of HTML code needs to use the OUT.PRINTLN function, that is, in Java embedded HTML, and JSP is based on HTML pages, When you need to write Java code, you insert Java code directly into the page, which is embedded in the HTML. A typical example is as follows:

JSP file:

<HTML>     <Body>       <H1>       <%Out.println ("JSP"); %>       </H1>     </Body>   </HTML> 

servlet file:

 Public class Myservlet ... {     ...     Out.println (");     Out.println ("<body>");     Out.println (");     Out.println ("Servlet");     out.println (");     Out.println ("</body>");     Out.println (");   

The JSP is easy to output, and the servlet facilitates logical processing. Therefore, the practical application of the two are often used in combination, their respective roles.

MVC model

The so-called MVC model is a method of separating data, logic processing and user interface.

    • M (model, models): For data processing, logic processing.
    • V (view): Used to display the user interface.
    • C (Controller, controllers): Control the logical direction and screen according to the client's request.

In Java, the three parts of MVC correspond to JavaBeans, JSP, and servlet, respectively.

    • M = JavaBeans: Used to pass data, with data-related logic processing.
    • V = JSP: Receive data from model and generate HTML
    • C = Servlet: Receive HTTP requests and control model and view

L--jsp and Servlets

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.