Basic JSP knowledge (1), basic JSP knowledge (
The role of web. xml:
1. Configure JSP, Servlet, Listener, Filter, tag library, and JSP attributes
2. Configure JAAS authorization authentication, resource application, and web homepage settings
The essence of JSP is Servlet (each JSP page in a web application is generated by the Servlet container)
JSP consists of static html page code and dynamic Java Script.
The source code of the Servlet class includes the init (), destroy (), and service () methods.
Four basic syntaxes of JSP:
Jsp comment: <% -- Comment -- %>
Jsp Declaration: <%! -- %> Used to declare variables and methods, which comply with the Java syntax. jsp declarations will be converted to variables and methods in the corresponding servlet class and will not exist independently.
Output jsp expression: <% = -- %> no additional points are allowed after the output expression
Jsp script: <% -- %> the jsp script is converted to executable code in jspservice. Therefore, this definition method is not used in the jsp script.
Three JSP compilation commands:
Page: for the current page
Example: <% @ page contentType = "text/html"; charset = "GBK" language = "java" errorPage = "" %>
Include: used to specify to include another page
Example: <% @ include file = "scriptlet. jsp" %>
Taglib: used to define and access custom tags
Seven action commands of JSP:
Jsp: forward: Page redirection
Jsp: param: Passing Parameters
Jsp: include: dynamically introduces a JSP page
Jsp: plugin: Download JavaBean or Applet to the client for execution
Jsp: useBean: Create a JavaBean instance
Jsp: setProperty: Set the attribute value of the JavaBean instance
Jsp: getProperty: attribute value of the output JavaBean instance