Author: zfive5 (zhaozidong) email: zfive5@yahoo.com.cn
These days waiting for the headquarters notice, now take a little time to see JSP, I also wrote some simple JSP programs, yesterday, I used the anti-compilation method to write an article related to String, now once again compile Tools BLOG A JSP variable defined article, in order to understand the JSP variable definition and call mode, you can imagine what happiest thing is to know what the principle is it? In fact, such an anti-compilation tool can be found in the Frameworksdk / bin directory under the .NET platform. The proxy class generating tool for the server function class under the .NET Remoting can also be found here. I feel that the world is big, there is a good thing or tools, but because many reasons don't let everyone know, now I have a little understanding of the night! The only conclusion is - "Knowledge exchange and resource sharing!"
<%! Definition%> The difference between <% definition%> is as follows, everything is in the code.
JSP:
<% @ Page ContentType = "Text / HTML; Charset = GBK"%> <% int J = 1;%> <%! int J = 0;%>
<% = J%>
<% = THIS.J%> H1> body > html>
Reflexible Java JSP1_0002EJSP_Jsp.Class:
import java.io.IOException; import javax.servlet *;. import javax.servlet.http *;. import javax.servlet.jsp *;. import org.apache.jasper.runtime.HttpJspBase; import org.apache.jasper. Runtime.jspexception;
Public class JSP1_0002EJSP_JSP EXTENDS HTTPJSPBASE {
Public JSP1_0002EJSP_JSP () {j = 0;}
Public final void _jspx_init () THROWS JSPEXCEPTION {}
public void _jspService (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; String _value = null; try {if synchronized (this) {if (_ jspx_inited!) {_jspx_init () (_ jspx_inited!); _jspx_inited = true;}} _jspxFactory = JspFactory.getDefaultFactory (); response.setContentType ( "text / html; Charset = GBK "); PageContext = _jspxFactory.getPageContext (this, request, response," ", true, 8192, true); Application = pageContext.getServletContext (); config = pagecontext.getSe RVletConfig (); session = pageContext.getSession (); out = pageContext.get (); out.write ("/ r / n / r / n") ; // Definition method 1, only the definition defined here can only be used after the _jspservice member function, if you want to quote // righteous mode 2 can only use this application int J = 1; Out.write ("/ R / n / r / n "); out.write (" / r / n / r / n
/ r / nOut.Print (j); out.write ("/ r / n
/ r / n / r / n "); out.print (this.j); Out.write (" / r / n h1> / r / n body> / r / n html > / r / n ");} catch (throwable t) {if (out! = null && out.getBuffersize ()! = 0) out.clearbuffer (); if (pageContext! = null) PageContext.HandlePageException (t) Finally {if (_jspxfactory! = Null) _jspxfactory.releasePageContext (PageContext);}} // Definition method 2, <%! Xxxx> is a member variable of a class, if we define one // member in this JSP file The function, then only the variable of this method INT J; private static boolean _jspx_inited = false;
}
Haha!