session作用域变成application了,求助
<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* " errorPage= " " %>
<%@ include file= "conn.jsp "%>
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 冷锋论坛 </title>
</head>
<body>
<%
String p=request.getParameter( "past ");
if( "true ".equals(p))
{
if(session.getAttribute( "islogin ")==null)
{%> <%
String Uname=request.getParameter( "username ");
String pass=request.getParameter( "passwd ");%> <%
String sql= "select * from nembers where UserID= ' "+Uname+ " 'and userPass= ' "+pass+ " ' ";
ResultSet result=stmt.executeQuery(sql);%> <%
if (result.next())
{
request.getSession().setAttribute( "islogin ", "true ");
}
else
{%> <%
out.print( " <script language= 'JavaScript '> alert( '用户名称或密码不正确,请重新登陆 '); </script> ");
}%> <%
}
else
{
out.print( " <script language=\ "JavaScript\ "> alert(\ "您已经登陆了\ "); </script> ");
}
}
%>
<div align= "left ">
<table width= "756 " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<!--网页头部-->
<tr>
<td width= "778 " height= "105 " valign= "top "> <img src= "lengfeng.gif " width= "771 " height= "105 " /> </td>
</tr>
</table>
</div>
<div align= "left ">
<table width= "1008 " border= "1 " cellpadding= "0 " cellspacing= "0 ">
<!--导航栏-->
<HR>
<tr bgcolor= "#CCCC33 ">
<td width= "500 " height= "30 " valign= "middle "> <font color= "#000000 " size= "2 " face= "宋体 "> 欢迎您:游客(登陆|注册) </font> </td>
<td width= "508 "bgcolor= "#99CC66 " align= "center "> <font size= "+1 "> <strong> 快捷登陆 </strong> </font> </td>
</tr>
<tr bgcolor= "#CCCC33 ">
<td valign= "center "> <font color= "#000000 " size= "2 " face= "宋体 "> 您当前的位置:冷锋论坛-> 美女贴图 </font> </td>
<form action= "top.jsp?past=true " method= "post ">
<td valign= "center " bgcolor= "#FFFFFF "> <font size= "3 "> <strong> 用户名: <input type= "text " name= "username " width= "10 ">
密码: <input type= "password " name= "passwd " width= "10 "> </strong> </font>
<input type= "submit " name= "Submit " value= "登陆 "> </td>
</form>
</tr>
</table>
</div>
<div align= "left ">
<table width= "1008 " border= "1 " cellpadding= "0 " cellspacing= "0 ">
<!--导航栏-->
<HR>
<tr bgcolor= "#0033FF ">
<td width= "142 " height= "40 " valign= "center "> <font color= "#000000 " size= "2 " face= "宋体 "> <a href= "fatie.jsp "> <img src= "fatie.gif " width= "80 " height= "35 " border= "0 " align= "middle " /> </a>
<td width= "39 " valign= "middle "> <img src= "gonggao.gif "> </td>
<td width= "860 " bgcolor= "#6600FF " valign= "middle "> <strong> <font color= "#FFFFFF " size= "3 ">
<marquee valign= "center " height= "10 " direction= "left "> 1.如何成为一个优秀的jsp程序员?! 2.头晕目眩的分割线 </marquee> </font> </strong> </td> </tr>
</table>
</div>
</body>
</html>
代码如上,登陆后,关闭登陆页面,重新打开一个页面,点击登陆按钮,提示 "你已经登陆 ",而先将浏览器关闭,重新打开浏览器就能正常登陆,记得这样的作用域是application了,而我的代码是:request.getSession().setAttribute( "islogin ", "true ");不知道为何
[解决办法]
那个不是application,作用域还是session
一种是调用了cookie是浏览器存储了用户名,你没用--> 否定
再就是你没有把浏览器全关掉,仍有session,可能性很大
再有就是我不知道了,呵呵。。
[解决办法]
session 一般有一个规定的时间,tomcat的conf文件里web.xml 的 <session-config> <session-timeout> 30 </session-timeout> </session-config> ,这就是session失效的时间,你可以自己设置的!
[解决办法]
lz重新打开一个浏览器就是另外一个session。
如果lz是在浏览器里新建一个页面,那就是同一个iexplore.exe进程的不同线程,session是共享的。
[解决办法]
那就是同一个iexplore.exe进程的不同线程===> 客户端
session===============> 服务器端