<%@ page language="java" contentType="text/html; charset=GB18030"
    pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>session示例</title>
</head>
<body>
<center>
<%
Integer counter = (Integer)session.getAttibute("accessCount");
if(counter==null){
out.println("你是首次来访<br>");
counter = new Integer(0);
}
else{
out.println("欢迎回访<br>");
counter = new Integer(counter.intValue()+1);
}
session.setAttribute("accessCount",counter);
%>
<hr>
<%=counter %>
</center>
</body>
</html>这是jsp的代码
在eclipse中运行报错:
An error occurred at line: 12 in the jsp file: /sessionCounter.jsp
The method getAttibute(String) is undefined for the type HttpSession
网上找了半天都没有回答,帮忙解决下

解决方案 »

  1.   

    没有用,还是一样的错误。jsp里不用这样获取session的,直接用就行。在servlet或者bean里才要。所以这不是关键问题。
      

  2.   

    楼上是正解。Integer counter = (Integer)session.getAttibute("accessCount"); 
    难道你没有使用myeclipse,不然会提示错误的。
      

  3.   

    The method getAttibute(String) is undefined for the type HttpSessionLZ我看了下是你自己写错东西了
    应该是getAttribute("accessCount")少了个i
    我运行了下你的可以
      

  4.   

    是写错单词了getAttibute少了个r
      

  5.   

    (Integer)session.getAttibute("accessCount"); 
    应该是这句
      

  6.   

    <%
    Integer counter = (Integer) session.getAttribute("accessCount");
    if (counter == null) {
    out.println("你是首次来访 <br>");
    counter = new Integer(0);
    } else {
    out.println("欢迎回访 <br>");
    counter = new Integer(counter.intValue() + 1);
    }
    session.setAttribute("accessCount", counter);
    %>
    <hr>
    <%=counter%>这段代码我试了 
    没问题
      

  7.   

    Integer counter = (Integer)session.getAttibute("accessCount"); 
    getAttibute()方法写错了  getAttribute(); 应该是
      

  8.   

    The method getAttibute(String) is undefined for the type HttpSession 在HttpSession中没有getAttibute(String) 这个方法,只有  session.getAttribute();这个方法
      

  9.   

    为什么我的eclipse在编写jsp的时候经常不提示。搞了半天是这么个错