jsp全局变量与局部变量的区别
摘要:jsp全局变量与局部变量的区别
<%! 定义
%>与 <% 定义
%>区别如方法,一切尽在代码中。
Jsp:
<%@ page contentType="text/html; charset=GBK"
%>
<!--定义方式1 -->
<% int
j=1;%>
<!--定义方式2 -->
<%! int j=0;%>
<html>
<head>
<title>
jsp1
</title>
</head>
<body bgcolor="#ffffff">
<h1>
<!--
调用定义方式1技巧变量
-->
<%=j%>
<br>
<!--
调用定义方式2技巧变量
-->
<%=this.j%>
</h1>
</body>
</html>
反编译技巧Ja jsp1_0002ejsp_jsp.class:
import ja.io.IOException;
import jax.servlet.*;
import jax.servlet.http.*;
import jax.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(!_jspx_inited)
synchronized(this)
{
if(!_jspx_inited)
{
_jspx_init();