This is the 14th day of my participation in the August Text Challenge.More challenges in August.

👨🎓 author: Java Academic Conference

🏦 Storage: Github, Gitee

✏️ blogs: CSDN, Nuggets, InfoQ, Cloud + Community

💌 public account: Java Academic Party

🚫 special statement: the original is not easy, shall not be reproduced or copied without authorization, if you need to reproduce can contact xiaobian authorization.

🙏 Copyright notice: part of the text or pictures in the article come from the Internet and Baidu Encyclopedia, if there is infringement, please contact xiaobian as soon as possible. Wechat search public Java academic party contact xiaobian.

☠️ Daily toxic chicken Soup: The life you envy is the bitter you have not endured

👋 Hello! I am your old friend Java academic party, today to share a brief introduction to JSP and basic knowledge. JSP will Java code and specific changes in the content embedded in the static page, static page as a template, dynamic generation of part of the content. JSP introduces XML tags called “JSP actions” to invoke built-in functions. In addition, JSP tag libraries can be created and then used just like standard HTML or XML tags.

The JSP specification

1. JSP specification introduction

  • Comes from one of the JAVAEE specifications
  • The JSP specification specifies how to develop JSP files instead of ringing objects to write processing results into the response body development process
  • The JSP specification specifies how the Http server should call management JSP files

2. Disadvantages of the response object

  • Suitable for writing the results of processing with less data to the response body
  • If the number of processing results is large, use response objects to make development more difficult

3.JSP code parsing

<%----%> This is the annotation information format in JSP <! ----> You can also write comments in this formatCopy the code
<%@ page contentType="text/html; charset=UTF-8" language="java"%> <%--contentType this property represents the encoding passed to the browser in the JSP --%> <%--language="java"Means you can write Java in a JSP file --%>Copy the code

Important: YOU can write CSS, HTML, JS, Java code and so on in JSP files

##4. Java command writing format in JSP file

<% %> This is called the execution token, and only the content written in the execution token is treated as a Java command

Multiple execution tags can appear in JSP ** In JSP all execution tags as a whole (as an execution statement fast),

- Writing Java commands directly in a JSP file is not recognized by the JSP, and will only be written to the response body as a string - in the JSP file, Only content written in execution tags is treated as Java commands. Only Java language written in execution tags (<%%>) is treated as Java code. The < %// In a JSP file, only the content written in the execution tag is treated as a Java command
  // 1. Declare Java variables
  int num1 = 100;
  int num2 = 200;
  // 2. Declare the operation expression, numeric operation, relational operation, logical operation
  int num3 = num1 + num2;  // Do the math
  intnum4 = num1>num2? num1:num2;boolean num5 = num2>=200 && num1>=100;
  // 3. Declare control statements
  if(num2 > num1){
    
  }else{}for (int i = 0; i < 10; i++) {
    
  }
%>
```


Copy the code

4.Servlet and JSP division of labor

A clear division of labor

  • Servlet: responsible for dealing with business and get the treatment results — — — — — — — — — — — — — — — — — — — — — — — — — – hotel chef (according to the request to cook)

  • JSP: not responsible for the business, the main task is to write the result of processing in the Servlet to the response body ——- waiter (dish to the user)

Two, the call relationship between Servlet and JSP

  • After Servlet is finished, it usually applies to Tomcat for invoking JSP through request forwarding

How to realize data sharing between Servlet and JSP

  • The Servlet adds the result of the processing to the Request scope object (since it is requested from Tomcat by request forwarding)
  • The JSP file gets the result of processing from the request forward scope object at run time
  • JSP and Servlet to achieve data sharing
    • You can use the ServletContext global scope object (from the same website)
    • You can use HttpSession session scoped objects (from the same website and serving the same user)
    • You can use HttpServletRequest request scope objects (JSPS and servlets share the same request protocol package, share the same request object)

5. Http server call JSP file steps:

Http server [edit] and [compile] JSP file location

I saw the evidence under [work]

6. On iml file

  • Infomation of Module IML is the project configuration file of Intellij IDEA, which contains some configuration information of the current project. Equivalent to the ID card of a project module. When the module moves to another path, the contents of the IML file of the module will change. The old ones will be voided.

  • The IML file is a module file automatically created by Intellij IDEA for Java application development. It stores information about module development, such as a Java group, plug-in components, Maven components, etc. It may also store module path information, dependency information, and other Settings.

  • If you change the module’s path. The IML file corresponding to its module needs to be changed.

  • Procedure For creating an IML file

    • Under IDEA open New – Project Structure – Artifacts – click the plus sign above

    • Choose the following

      Select the new module you just imported and click OK to add a new IML text to the newly imported module

    • You can then set some properties for the module in the module Settings, such as importing several new JAR packages

URI format

/ Site name/resource name

——-💘 after watching the big guys can pay attention to the xiaobian, will always update the small skills, free to share with you!! 💝—– today first share here, tomorrow to continue to share with you, pay attention not lost yo, we will see 😊 tomorrow.