关于用户登陆问题,请高手进来。 有一个登陆页面,开始用A用户登陆,登陆后再打开登陆页面,再用B用户登陆,登陆完毕后"刷新"A登陆后的页面你会发现用户就变成B了.请问这个该怎末解决阿?sohu的邮件登陆就是这样的!不信大家可以去试一下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这么简单的一个问题,就是登录成功后往session里面放了一样东西(姑且叫userInfo),页面/业务逻辑都会依赖这个userInfo 我估计是线程不安全引起的问题,比如,你的程序代码要对session进行处理,而在处理过程中,可能是两个session都在请求这个方法。这样,两个session中的内容就发生了混乱。只要再你的相关方法前加上 synchronized 关键字,就可以解决同步问题了! heh e关注,满有趣的问题 打开2个IE窗口,不要在一个IE窗口中用鼠标右键“在新窗口中打开”,而是要“在开始-》程序-》IE”这样打开两次 to shine333(enihs) :能说清楚点吗?to zeq258(近朱者赤):有那么复杂吗?to ustcfrank(阿卡波糖) :不能这样限制客户呀!CSDN的登陆就可以分开 用COOKIES会话跟踪 这个用Servlet写比较方便 up songlijun7(我一定行) 能详细点更好 是不是你a登录时候session.setAttribute("UserID",a),然后b登录,又session.setAttribute("UserID",b),所以导致这样? 如果把用户信息放在session中,并且a和b开两个窗口,属于两个session,根本不会出现这种情况 我做了一个简单的提供参考-------------------------------------------------------------------login.htm<html><head> <title>系统登陆</title></head><body bgcolor="#FFFFFF"> <center> <h2>系统登陆</h2> <form action="login.jsp" method="post"> <Input type="text" name="uid" maxlength=8 style="width:150"><br> <Input type="password" name="upwd" maxlength=8 style="width:150"><br> <Input type="submit" value="登陆"> <Input type="reset" value="取消"> </form> </center> </body></html>-------------------------------------------------------------login.jsp<%@ page contentType="text/html;charset=GB2312" %><% if(request.getParameter("uid").equals("jenny") && request.getParameter("upwd").equals("jenny")) { session.setAttribute("login","ok"); session.setAttribute("name","jenny"); session.setMaxInactiveInterval(-1);%> <jsp:forward page="main2.jsp"/><% } else if(request.getParameter("uid").equals("wanghfc") && request.getParameter("upwd").equals("wanghfca")){ session.setAttribute("login","ok"); session.setAttribute("name","wanghfc"); session.setMaxInactiveInterval(-1); %> <jsp:forward page="main2.jsp"/> <% } else { out.println("用户名或密码输入错误!"); }%>---------------------------------------------------------------main2.jsp<%@ page contentType="text/html;charset=GB2312" %><HTML> <head> <title>Welcome to my homepage</title> </head> <body> Welcome to my homepage name: <%=session.getAttribute("name")%> </body></HTML>这个是不会更改的,因为是刚刚提交的。在看下面的代码。 login.htm,main2.jsp 都不变变动的有login.jsp,<jsp:forward page="main2.jsp"/>转向main.jsp-----------------------------------------------------------------------login.jsp<%@ page contentType="text/html;charset=GB2312" %><% if(request.getParameter("uid").equals("jenny") && request.getParameter("upwd").equals("jenny")) { session.setAttribute("login","ok"); session.setAttribute("name","jenny"); session.setMaxInactiveInterval(-1);%> <jsp:forward page="main.jsp"/><% } else if(request.getParameter("uid").equals("wanghfc") && request.getParameter("upwd").equals("wanghfca")){ session.setAttribute("login","ok"); session.setAttribute("name","wanghfc"); session.setMaxInactiveInterval(-1); %> <jsp:forward page="main.jsp"/> <% } else { out.println("用户名或密码输入错误!"); }%>---------------------------------------------------------------main.jsp只写了这样一句话main.jsp<%@ page contentType="text/html;charset=GB2312" %><HTML> <head> <title>默认主页</title> </head> <body> 欢迎进入本页面 <A HREF="main2.jsp">跳转到后续页面</A> </body></HTML> lz你先找一下资料,看看什么是Session,否则不是一句两句可以说明白的 求助,在线等,分页后出的问题 JFreechart 获取map里的参数乱码。求解 各位老大,帮忙看看我怎样用xslt输出下面这个xml的数据? javabean菜鸟问题~! 请问jsp里面停止输出,类似asp“response.end”这样的语句应该怎么写呢? 一个简单的问题,急~ 帮帮忙!jspSmartUpload的安装及用法的问题 提前几天散点分,祝大家新年快乐! 高分!求一简单问题。100分 JDBC有限制吗? webwork于SPRING整合问题,急!!! html和jsp中有嵌套的引号怎么处理?
关注,
满有趣的问题
to zeq258(近朱者赤):有那么复杂吗?
to ustcfrank(阿卡波糖) :不能这样限制客户呀!CSDN的登陆就可以分开
-------------------------------------------------------------------
login.htm
<html><head>
<title>系统登陆</title>
</head><body bgcolor="#FFFFFF">
<center>
<h2>系统登陆</h2>
<form action="login.jsp" method="post">
<Input type="text" name="uid" maxlength=8 style="width:150"><br>
<Input type="password" name="upwd" maxlength=8 style="width:150"><br>
<Input type="submit" value="登陆">
<Input type="reset" value="取消">
</form>
</center>
</body>
</html>
-------------------------------------------------------------login.jsp
<%@ page contentType="text/html;charset=GB2312" %><%
if(request.getParameter("uid").equals("jenny") && request.getParameter("upwd").equals("jenny")) {
session.setAttribute("login","ok");
session.setAttribute("name","jenny");
session.setMaxInactiveInterval(-1);
%>
<jsp:forward page="main2.jsp"/>
<%
}
else if(request.getParameter("uid").equals("wanghfc") && request.getParameter("upwd").equals("wanghfca")){
session.setAttribute("login","ok");
session.setAttribute("name","wanghfc");
session.setMaxInactiveInterval(-1);
%>
<jsp:forward page="main2.jsp"/>
<%
}
else {
out.println("用户名或密码输入错误!");
}
%>
---------------------------------------------------------------
main2.jsp
<%@ page contentType="text/html;charset=GB2312" %><HTML>
<head>
<title>Welcome to my homepage</title>
</head> <body>
Welcome to my homepage
name: <%=session.getAttribute("name")%>
</body></HTML>这个是不会更改的,因为是刚刚提交的。
在看下面的代码。
变动的有login.jsp,<jsp:forward page="main2.jsp"/>转向main.jsp
-----------------------------------------------------------------------
login.jsp
<%@ page contentType="text/html;charset=GB2312" %><%
if(request.getParameter("uid").equals("jenny") && request.getParameter("upwd").equals("jenny")) {
session.setAttribute("login","ok");
session.setAttribute("name","jenny");
session.setMaxInactiveInterval(-1);
%>
<jsp:forward page="main.jsp"/>
<%
}
else if(request.getParameter("uid").equals("wanghfc") && request.getParameter("upwd").equals("wanghfca")){
session.setAttribute("login","ok");
session.setAttribute("name","wanghfc");
session.setMaxInactiveInterval(-1);
%>
<jsp:forward page="main.jsp"/>
<%
}
else {
out.println("用户名或密码输入错误!");
}
%>
---------------------------------------------------------------
main.jsp只写了这样一句话
main.jsp
<%@ page contentType="text/html;charset=GB2312" %><HTML>
<head>
<title>默认主页</title>
</head> <body> 欢迎进入本页面
<A HREF="main2.jsp">跳转到后续页面</A> </body></HTML>