In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "JSP grammar, instructions, expressions and objects of knowledge collation", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "JSP grammar, instructions, expressions and objects of knowledge collation" bar!
JSP syntax
. . .
Script program
A script can contain any number of Java statements, variables, methods, or expressions, as long as they are valid in the scripting language.
The syntax format of the script: alternatively, you can write its equivalent XML statement, like this:
Code snippet
Any text, HTML tags, JSP elements must be written on the outside of the script.
Note: make sure that Apache Tomcat is installed in the C:\ apache-tomcat-7.0.2 directory and that the running environment is set up correctly.
Save the above code in hello.jsp, then place it in the C:\ apache-tomcat-7.0.2\ webapps\ ROOT directory, open a browser and enter http://localhost:8080/hello.jsp in the address bar.
. . .
JSP statement
A declaration statement can declare one or more variables and methods for use by subsequent Java code. In the JSP file, you must declare these variables and methods before you can use them.
The syntax format of the JSP declaration: alternatively, you can write its equivalent XML statement, like this:
Code snippet
. . .
JSP expression
A scripting language expression contained in an JSP expression is first converted to String and then inserted where the expression appears.
Because the value of the expression is converted to String, you can use the expression in a line of text regardless of whether it is a HTML tag or not.
An expression element can contain any expression that conforms to the Java language specification, but you cannot end the expression with a semicolon.
Syntax format for JSP expressions: similarly, you can write equivalent XML statements:
Expression.
. . .
JSP comment http://www.iis7.com/a/lm/zzxzgj/
JSP comments have two main functions: commenting code and commenting out a piece of code.
Syntax format of JSP comments:
Syntax rules for using annotations in different situations:
Grammatical description
JSP comments, the comment content will not be sent to the browser or even compiled
HTML comments, which can be seen when viewing the source code of a web page through a browser
Constant
\ 'single quotation marks used in attributes
\ "double quotation marks used in attributes
. . .
JSP instruction
The JSP directive is used to set properties related to the entire JSP page.
JSP instruction syntax format:
There are three kinds of instruction tags:
Instruction description
Define the dependency properties of the page, such as scripting languages, error pages, caching requirements, and so on
Include other files
Introduce the definition of tag library, which can be a custom tag
. . .
JSP behavior
The JSP behavior tag uses the servlet syntax structure to control the XML engine. It can dynamically insert a file, reuse JavaBean components, guide users to another page, generate relevant HTML for Java plug-ins, and so on.
There is only one syntax format for the behavior tag, which strictly adheres to the XML standard:
Behavior tags are basically pre-defined functions. Here are some available JSP behavior tags:
Grammatical description
Jsp:include is used to include static or dynamic resources in the current page
Jsp:useBean finds and initializes a JavaBean component
Jsp:setProperty sets the value of the JavaBean component
Jsp:getProperty inserts the value of the JavaBean component into output
Jsp:forward passes a request object containing user requests from one JSP file to another
Jsp:plugin is used to include Applet and JavaBean objects in the generated HTML page
Jsp:element dynamically creates a XML element
Jsp:attribute defines the attributes of dynamically created XML elements
Jsp:body defines the body of a dynamically created XML element
Jsp:text is used to encapsulate template data
. . .
JSP implied object
JSP supports nine automatically defined variables, known as implicit objects. A brief introduction to these nine implicit objects is shown in the following table:
Object description
Instance of the request HttpServletRequest class
Instance of the response HttpServletResponse class
An instance of the out PrintWriter class, which is used to output the results to a web page
Instance of the session HttpSession class
An instance of the application ServletContext class, depending on the application context
Instance of the config ServletConfig class
An instance of the pageContext PageContext class that provides access to all objects and namespaces on the JSP page
Page is similar to the this keyword in the Java class
The object of the Exception Exception class, which represents the corresponding exception object in the JSP page where the error occurred
. . .
Control flow statement
JSP provides full support for the Java language. You can use Java API or even build blocks of Java code in JSP programs, including judgment statements, loop statements, and so on.
. . .
Judgment sentence
If... Else block
. . .
Loop statement
Three basic loop types of Java can be used in JSP programs: for,while, and do. While .
. . .
JSP operator
JSP supports all Java logical and arithmetic operators.
The following is a list of common JSP operators, from high to low:
Category operator associativity
Suffix () []. (dot operator) left to right
Unary + + -! ~ right to left
Multiplicability * /% left to right
Additivity +-left to right
Shift > =
< >=
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.