JSP is an extension of Servlet. Before JSP appeared, Servlet technology had already appeared. Servlet uses "output stream" to dynamically generate HTML pages. Including every HTML tag and all the content that appears in the HTML page. To put it simply, it uses the output stream of the Servlet to generate an HTML page from the HTML tag. Over time, Servlets contained a large number of HTML tags, a large amount of static text and formats, etc., resulting in very low development efficiency of Servlets.
At this time, JSP was born , JSP makes up for this situation. JSP embeds JAVA code in standard THML pages so that the static parts do not need to be controlled by JAVA programs. Only those page contents that need to be read from the database or need to be dynamically generated can be controlled by JAVA scripts. .
JSP is mainly composed of two parts:
(1) Static part: standard HTML tags, static page content, these contents are the same as static HTML pages.
(2) Dynamic part: Content controlled by Java program, which is dynamically generated by Java program.
The following is the simplest piece of jsp code:
<title>欢迎</title> 欢迎学习Java JSP!现在时间是:
The bold code on the page is placed between , indicating that these are Java scripts, not static Content, in this way, Java code can be embedded in the HTML page, which becomes a dynamic JSP page. From a superficial analysis, JSP pages no longer require Java classes and seem to be completely divorced from the object-oriented characteristics of Java. However, in fact, JSP is a special form of Servlet. Each JSP page is an instance of Servlet. .
Working principle
(1) When a user accesses a JSP page, a Servlet container (Tomcat) issues a request;
(2) If it is the first time to request the page, or the page has been changed, the servlet container must first convert the JSP page (assumed to be test.jsp) into Servlet code (test.java), and then convert it into (test. class file); because this process (compilation) will take a certain amount of time, the access time is a bit long when accessing for the first time or when the jsp file is modified;
(3) The JSP container is responsible for calling the JSP converted from servlets, these servlets are responsible for providing services to corresponding user requests (for example, the client sends a form and requires servlet: formprocessor.java to process it, the container will create a thread and call formprocessor.java to process the request); if the user has multiple requests, The container will create multiple threads to handle multiple requests;
(4) The container executes the bytecode file (including the called servlet: formprocessor.java bytes) and returns the results to the client; (The final way to return is to have a servlet output a file stream in html format)
Note:
The JSP page must be run in a JSP server, such as tomcat weblogic, jboss Wait. (By the way, apache and tomcat are two different things. Many people think that
apache is tomcat, which is actually a wrong understanding!~, tomcat is just a sub-project of apache, and apache is used as a WEB application server , and tomcat can be said to be a web container of JSP or Servlet);
Visitors to the JSP page do not need to install any client, or even a running environment that can run Java, because the JSP page is delivered to the client as a standard HTML page .
Related learning recommendations: java basic tutorial
The above is the detailed content of How does jsp work?. For more information, please follow other related articles on the PHP Chinese website!

jsp属于后端。jsp的本质是一种servlet,而servlet又是服务器端的java应用程序,所以jsp是属于后端的技术。JSP部署于网络服务器上,可响应客户端发送的请求,并根据请求内容动态地生成HTML、XML或其他格式文档的Web网页,然后返回给请求者。JSP技术以Java作为脚本语言,为用户HTTP请求提供服务,并能与服务器上的其它Java程序共同处理复杂的业务需求。

新建好springboot项目以后目录如下:第一步:在项目的pom文件中加入配置jsp所需要的jar包代码:org.apache.tomcat.embedtomcat-embed-jasperprovided第二步:在main路径下新建目录webapp,在webapp下新建路径WEB-INF,在WEB-INF下新建路径jsp,在这个路径下放置我们要使用的jsp文件第三步:在主配置文件中配置jsp文件的访问路径和后缀代码:spring.mvc.view.prefix=/WEB-INF/jsp/sp

实现步骤:1、在JSP页面中引入JSTL标签库;2、从数据库中获取数据;3、对数据进行分页处理;4、在页面中显示分页导航条;5、根据当前页码和每页显示数量,从分页后的数据中获取对应的数据并显示在页面上即可。

jsp和html区别:1、运行机制;2、用途;3、与Java的关系;4、功能;5、与后端的关系;6、速度;7、可维护性和扩展性;8、学习和使用的难易程度;9、文件后缀和识别工具;10、社区和支持;11、安全性。详细介绍:1、运行机制,HTML是一种标记语言,主要用于描述和定义网页的内容,它运行在客户端,由浏览器解释执行,JSP是一种动态网页技术,运行在服务器端等等。

一、实现分页查询的核心sql语句(1)查询数据库的记录总数的sql语句:selectcount(*)from+(表名);(2)每次查询的记录数的sql语句:其中:0是搜索的索引,2是每次查找的条数。select*from表名limit0,2;二、代码实现*上篇写过这两个类,DBconnection类:用于获取数据库连接,Author对象类。这两个类的代码点击连接查看。点击链接查看DBconnection类和Author对象类(1)登录页面:index.jsp。Inserttitlehere用户列

JavaWeb开发技术栈:掌握JavaEE、Servlet、JSP、Spring等用于Web开发的技术随着互联网的迅速发展,在当今的软件开发领域,Web应用的开发已经成为一种非常重要的技术需求。而Java作为一种广泛应用的编程语言,其在Web开发领域也有着重要的地位。JavaWeb开发技术栈涉及多项技术,如JavaEE、Servlet、JSP、Spr

JSP是一种动态网页技术标准,其文件格式是在传统的网页HTML文件(.htm,.html)中插入Java程序段(Scriptlet)和JSP标记(tag),从而形成JSP文件(*.jsp)。

jsp中iframe是一种用于嵌入其他网页或文档的HTML标签,可以实现页面的分割、动态加载、异步加载和跨域访问等功能。它为开发人员提供了更多的灵活性和交互性,可以提高网页的可用性和用户体验。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
