小弟做拉两个jsp页面 其中一个是得到客户端访问次数的count.jsp, 另一个test.jsp include count.jsp,但是当访问test.jsp是 老是显示:欢迎光临!该页面已被访问1次。怎样才能解决上面的问题呢?以下是两个jsp页面代码:
count.jsp:   
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
  int count=1;
  String name=request.getParameter("name");
  try{
       count=Integer.parseInt((application.getAttribute(name).toString()));
  }
  catch(Exception e){
  }
  out.print("欢迎光临!该页面已被访问"+count+"次。");
  count++;
  application.setAttribute(" ",new Integer(count));
 %>test.jsp:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page info="计数器" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<jsp:include page="count.jsp">
<jsp:param name="name" value="test"/>
</jsp:include>
</body>
</html>
请高手们接分,帮我解决!!!

解决方案 »

  1.   

    int count=1;-->static int count=1;试试!
      

  2.   

    还有application.setAttribute(" ",new Integer(count));是不是应该改成application.setAttribute(name,new Integer(count));
      

  3.   

    小弟还有个问题不知道写得对不对 这句application.setAttribute(" ",new Integer(count));
    有没有毛病?
      

  4.   

    new Integer(count)前一个参数应该是字符串形式把???
      

  5.   

    application.setAttribute(" ",new Integer(count));没有问题,不过你取的时候要application.getAttribute(" ")拉!
    new Integer(count)前一个参数应该是字符串
    LZ可以看看JSP的内置对象的说明,网上很多滴^_^