Acquaintance JSP: JSP notes, scripts, statements, expressions

1.JSP comments

In the HTML which, if we can use the traditional notes on the client, which is the right to view the source code for the page on which the comment visible, but can not see the comments in the JSP client in. JSP source code which will only see where noted vacated.

Instructions:

<% - This is a jsp comment, the client is not visible - %>

Intellji IEDA of JSP comments are shortcut keys: Ctrl + /

 

2.JSP script

JSP script can embed Java code in the HTML code.

Instructions:

<%
     // This is a java code can be written in JSP scripting
     // Note that there can not comment jsp method of 
    out.println ( "Hello, everyone, here is a passage Java language output" );
 %>

 

3.JSP statement

Since it uses JSP script to write Java code, a variety of variables and methods is essential. In fact, jsp scripts can also declare a variable, but the method can not be declared.

Instructions:

<%!
   // Not only can declare a variable, you can declare methods. Jsp but not written in the java script Method 
  int COUNT ( int X, int Y) 
  { 
    return X + Y; 
  }
 %> 

<% // then in the script may invoke int A = 10 ; 
    Out.println (A); 
    OUT. the println (COUNT ( 10,20 ));
 %>
    
    

 

4.JSP expression

In some cases, variable declarations JSP pages need to be embedded into a certain part of the display, then you can use JSP expressions

Instructions:

<h1>a=<%=a%>  10+20=<%=count(10,20)%></h1>

 

Guess you like

Origin www.cnblogs.com/lbhym/p/11498530.html
jsp