当前位置: 代码迷 >> Java Web开发 >> 奇怪的异常
  详细解决方案

奇怪的异常

热度:342   发布时间:2016-04-17 10:46:23.0
奇怪的错误

做一个登录的功能,转向页面index.jsp

out.println("登陆成功");
  session.setMaxInactiveInterval(60000);
  session.setAttribute("username",username);
  String userid = rs.getString("userid");
  session.setAttribute("userid", "userid");
  session.setAttribute("fullname", rs.getString("fullname"));
  session.setAttribute("logins", rs.getString("logins"));
  session.setAttribute("rights", rs.getString("rights"));
  session.setAttribute("depid", rs.getString("depid"));
  session.setAttribute("mygroups", rs.getString("groups"));
 
  String lastip = req.getRemoteAddr();
  String update = "UPDATE userinfo SET lastlogin='" + date.toLocaleString() + "',logins=logins+1 where userid=" + userid;
  String update1 = "INSERT into Log(username,uptime,lastip,content) VALUES('" + username + "','" + date.toLocaleString() + "','" + lastip + "','登陆系统')";
 
  int n = sql1.executeUpdate(update1);
  int f = sql1.executeUpdate(update);
 
  resp.sendRedirect("index.jsp");

结果并没有执行到index.jsp
后台也没报错
前台只显示了登录成功
数据库内没有内容(oracle)

请问是什么问题?

session.setMaxInactiveInterval(60000);设置断点调试的内容大致如下,但是没看到问题

this Login (id=61)
req RequestFacade (id=66)
resp ResponseFacade (id=70)
out CoyoteWriter (id=74)
session StandardSessionFacade (id=81)
username "admin" (id=83)
pwd "admin" (id=88)
searchinfo "select * from userinfo where username=? and pwd=?" (id=94)
boo true
date Date (id=99)
conn OracleConnection (id=85)
sql1 OracleStatement (id=101)
sql OraclePreparedStatement (id=108)
rs OracleResultSetImpl (id=112)
m true
userid "1" (id=183)
lastip "127.0.0.1" (id=184)
update "UPDATE userinfo SET lastlogin='2012-2-23 22:37:33',logins=logins+1 where userid=1" (id=185)
update1 "INSERT into Log(username,uptime,lastip,content) VALUES('admin','2012-2-23 22:37:33','127.0.0.1','登陆系统')" (id=186)


求帮助



------解决方案--------------------
探讨
关键问题在:“out.println("登陆成功");”

一旦你向浏览器发送了任何内容后,就不能再发送sendRedirect了,或者说发送了也没效果了。
  相关解决方案