question about the difference between <% and <%!
I'm sorry that I can't type Chinese because the computer in our company has not been installed with a pinyin input method(The OS language is traditional Chinese) but I'm not authorized to install any software. It's the company's rule.
The question is the difference between "<% %>" and "<%! %>".
I know the code in <%! %> is declaration and no output is allowed in the exclamation point(<%! %>) while any correct java code is allowed in <% %>.
It means only variable and method declaration is allowed in <%! %> and the declaration statement should be complete java statement and it must end with a semicolon.
Example using "<%!":
<%!
public String str="hello";
public void Test()
{
}
%>
But we can also declare variable and method in <% %>.
Example using "<%":
<%
public String str="hello";
public void Test()
{
}
%>
The question is why we still need a exclamation point(<%!) to write a declaration statement? When do we have to use <%!%> only?
Thanks.