JSP directives:
page, usually at the top of the JSP page, can have multiple page directives on the same page
Include, embed an external file into the current JSP file, and parse the JSP statements in this page
Taglib, using the tag library to define a new custom label, start the custom behavior in the JSP page
Page instruction Syntax:
<% @page Property 1 = "" Property 2= "" ...%>
Property:
Language, specifying the scripting language used by JSP pages, default Java
Import, which refers to the class file used in the scripting language, with no default value
ContentType, used to specify the encoding method used by the JSP page, the default value cannot be parsed in Chinese, generally write contenttype= "text/html; Charset=utf-8"
JSP comments:
Comments in HTML:<!--HTML annotations-->//client visible
Comments in JSP: <%--jsp comment--%>//Client not visible
JSP script Comment: <%//or/**/%>//single row, multiple lines, not visible
JSP declaration:
Defining variables or methods in a JSP page
Syntax: <%! Java Code%>
<%! String s= "xiaoming"; int Add (int x,int y) { return x+y; } %>
JSP expression:
Expressions that are executed in a JSP page
Syntax: <%= expression%>//Note that the expression does not end with a semicolon!
Hello, <%=s%><br>1+1=<%=add (10,5)%>
<%= variable%> is a shorthand for <% out.println (variable)%>
Display the date on the page:
First you need to import, date package
<% @page import= "Java.util.Date"%>
Then you need to get the current date:
<% simpledateformat nowdate=new simpledateformat ("yyyy year mm DD Day"); String s=nowdate.format (new Date ()); %> today is:<%=s%>
JSP basic syntax