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.
JSP is a scripting language that wraps the interface of a Java servlet system, simplifies the use of Java and Servlets, and provides the ability to dynamically execute a Web page by extending the JSP tag (tag). JSP provides a simple set of tags, and HTML fusion is better, so that people who do not understand the servlet can make dynamic Web pages. For people who are unfamiliar with the Java language, they will find JSP development more convenient. JSP changes can immediately see the results, do not need to compile manually, the JSP engine will do the work, and Servelt need to compile, restart the servlet engine and a series of actions. But in JSP, the HTML is mixed with the program code, and the servlet is not. Below we do a simple introduction to the operation of JSP, tell you how to execute a JSP file: When the Web server (or servlet engine, application Server) support JSP engine, JSP engine will follow the syntax of JSP, the JSP file into the servlet code source file, Then the servlet will be compiled into Java executable bytecode (bytecode), and loaded into the normal servlet execution JSP syntax is simple, can be easily embedded in the HTML, it is easy to add dynamic parts, easy to output HTML. The output of HTML in the servlet needs to call a specific method, the quotation marks and other characters to do special processing, add to the complex HTML page as a dynamic part, compared to JSP is more difficult.
The "1" JSP is compiled into a servlet the first time it is run and resides in memory for invocation.
"2" JSP is a Web development technology, Servlet is a server-side application of small programs, when we visit a JSP page, the server will turn this JSP page into a servlet applet run results, feedback to the client browser.
The "3" servlet corresponds to a control layer to invoke the corresponding JavaBean processing data, and finally returns the result to the JSP.
The "4" servlet is primarily used for steering, turning requests to the appropriate JSP pages.
"5" JSP more is the page display, servlet is more processing business, that is, JSP is a page, servlet is the way to implement JSP.
The "6" servlet can implement all the functions of the JSP, but since the artist uses the servlet to make the interface very difficult, the JSP was later developed.
"7" JSP technology development Site two modes: JSP + javabean;jsp + Servlet + JavaBean (generally in multi-tier applications, JSP is mainly used as the presentation layer, and the Servlet is used as the control layer, because too much code in the JSP is not conducive to maintenance, This is left to the servlet, and a lot of repeating code is written in JavaBean.
"8" The difference between the two is that the development interface is JSP directly can be written.
For example, write the table tag in the JSP: <table>[data]</table>;
The servlet needs to join: Out.println ("<table>[data]</table>").
JSP files are compiled into servlet files after they have been called by the application server (for example: Tomcat, Resin, WebLogic, and WebSphere). This means that the servlet file is actually displayed on the Web page. Tomcat the resulting servlet file after compiling the JSP file is placed under the work folder, and the HTML code in the JSP is out of the servlet, and the JSP code is placed in a different location depending on the label.
Java code is embedded in the "9" JSP, and HTML code is embedded in the servlet.
"10" in a standard MVC architecture, the servlet takes a user request as a controller and forwards it to the corresponding action handler, which is primarily used to generate dynamic pages as a view, and EJB implements your business code as a model.