The full name of JSP is Java Server Pages, which is a dynamic web page development technology. It uses JSP tags to insert Java code in HTML web pages. Tags usually start with <% and end with %>.
JSP is a Java servlet that is mainly used to implement the user interface part of Java web applications. JSP can be written using HTML code, JS code, CSS code, Java code snippets, and embedded JSP operations and commands.
JSP obtains user input data through web forms, accesses databases and other data sources, and then dynamically creates web pages.
JSP tags have a variety of functions, such as accessing databases, recording user selection information, accessing JavaBeans components, etc., and can also transfer control information and shared information in different web pages.
Advantages of JSP
Compared with ASP:
The dynamic part is written in Java, so it is more powerful and easy to use and can be transplanted to many different Server and operating system
Compared with PHP:
Better tool support
Compared with Servlet:
Creating HTML is more convenient
Compare with Javascript:
How it works
The following steps show how the web server uses JSP to create a web page:
Just Like any other normal web page, your browser sends an HTTP request to the server.
The Web server recognizes that this is a request for a JSP web page and passes the request to the JSP engine. This is done using a URL or a .jsp file.
The JSP engine loads JSP files from disk and converts them into servlets. This transformation simply converts all template text into println() statements and converts all JSP elements into Java code.
The JSP engine compiles the servlet into an executable class and passes the original request to the servlet engine.
A certain component of the Web server will call the servlet engine, and then load and execute the servlet class. During execution, the servlet generates output in HTML format and embeds it in the HTTP response and submits it to the Web server.
The Web server returns the HTTP response to your browser in the form of a static HTML web page.
Ultimately, the web browser processes the dynamically generated HTML web pages in the HTTP response as if it were a static web page.
The above is the detailed content of What language is used for jsp?. For more information, please follow other related articles on the PHP Chinese website!