Introduction to Java--JSP

Posted Jun 26, 20203 min read

Introduction to Java--JSP

Blog description

The information involved in the article comes from the Internet collation and personal summary, which means personal learning and experience summary. If there is any infringement, please contact me to delete, thank you!

Description

JSP(full name JavaServer Pages) is a dynamic web technology standard created by Su company. JSP is deployed on the web server, can respond to the request sent by the client, and dynamically generate Web pages of HTML, XML or other format documents according to the content of the request, and then return it to the requester. JSP technology uses Java language as a scripting language to provide services for users' HTTP requests, and can handle complex business requirements together with other Java programs on the server.

It can be understood as:a special page, in which you can specify the definition of html tags, you can also define the java code

Principle

JSP is essentially a Servlet

JSP script

How JSP defines Java code

  1. <%code%>:The defined java code is in the service method. What can be defined in the service method, what can be defined in the script.
  2. <%! code%>:the defined java code, the member position of the java class after jsp conversion.
  3. <%= Code%>:The defined java code will be output on the page. What can be defined in the output statement, what can be defined in the script.

Built-in objects of JSP

  • Objects that can be used directly without getting and creating in jsp pages

    • out:JSPWriter, used to write the data of the response stream
    • page:servlet itself
    • pageContext:A PageContext instance includes data related to the entire page, and a given HTML page can be passed between multiple JSPs.
    • request:HTTP request(request) object
    • response:HTTP response(response) object
    • session:HTTP session(server session) object

JSP action

JSP actions are a series of XML tags that can call functions built into the web server. JSP provides the following actions:

jsp:include Similar to the subprocess, JAVA SERVLET temporarily takes over requests and responses to other specified JSP pages. When the JSP page is processed, control is immediately returned to the current JSP page. This way the JSP code can be shared among multiple JSP pages without copying.
jsp:param Can be used between jsp:include, jsp:forward or jsp:params blocks. Specify a parameter that will be added to the current parameter group of the request.
jsp:forward Used to process requests and responses to another JSP or SERVLET. Control is never returned to the current JSP page.
jsp:plugin Netscape Navigator uses different tags to embed an applet. This action generates the specified browser tag required to embed an APPLET.
jsp:fallback What will be displayed if the browser does not support APPLETS.
jsp:getProperty Get a property value from the specified JavaBean.
jsp:setProperty Set a property value in the specified JavaBean.
jsp:useBean Create or reuse a JavaBean variable to a JSP page.

Why use JSP

JSP programs have similar functions to CGI programs, but compared to CGI programs, JSP programs have the following advantages:

  • The performance is more superior, because JSP can directly embed elements in HTML web pages without the need to separately reference CGI files.
  • The server calls the compiled JSP file, unlike CGI/Perl, you must first load the interpreter and target script.
  • JSP is based on the Java Servlet API, therefore, JSP has a variety of powerful enterprise-level Java APIs, including JDBC, JNDI, EJB, JAXP, etc.
  • JSP pages can be used with servlets that handle business logic. This model is supported by the Java servlet template engine.

Finally, JSP is an integral part of Java EE and is a complete enterprise-level application platform. This means that JSP can implement the most complex applications in the simplest way.

thank

Baidu Encyclopedia

Rookie tutorial

And hardworking self