CheckUser.jsp
上传用户:nbluoke
上传日期:2013-08-09
资源大小:4851k
文件大小:2k
源码类别:

教育系统应用

开发平台:

WORD

  1. <%@ page contentType="text/html; charset=GB2312" %>
  2. <%@ page import="jinghua.CheckUser" %>
  3. <%@ page import="jinghua.*" %>
  4. <%!//处理中文字符串
  5.   public String codestring(String s){
  6. String str=s;
  7. try{
  8. byte b[]=str.getBytes("ISO-8859-1");
  9.   str=new String(b);
  10.   return str;
  11. }
  12. catch(Exception e){
  13. return str;
  14. }
  15. }
  16. %>
  17. <jsp:useBean id="login" class="jinghua.CheckUser" scope="session">
  18. </jsp:useBean>
  19. <%//提交信息后,验证是否正确
  20. String message="",
  21.   logrole="",
  22.   logname="",
  23.   password="";
  24. //if(!(session.isNew())){
  25. logrole=request.getParameter("logrole");
  26. if(logrole==null) logrole="";
  27. logrole=codestring(logrole);
  28. logname=request.getParameter("logname");
  29. if(logname==null) logname="";
  30. logname=codestring(logname);
  31. password=request.getParameter("password");
  32. if(password==null) password="";
  33. password=codestring(password);
  34. //}
  35. %>
  36. <%
  37. if(!(logname.equals(""))){
  38. %>
  39. <jsp:setProperty name="login" property="logrole" value="<%=logrole%>"/>
  40. <jsp:setProperty name="login" property="logname" value="<%=logname%>"/>
  41. <jsp:setProperty name="login" property="password" value="<%=password%>"/>
  42. <%
  43. message=login.getMessage();//获取返回的验证信息
  44. if (message==null) message="";
  45. }
  46. %>
  47. <%
  48. session.setMaxInactiveInterval(60*60);
  49. //Tools.debugPrintln("session.setMaxInactiveInterval(60*60*2))");
  50. if(!(session.isNew())){
  51. if(message.equals("OK"))  {
  52.   if(logrole.equals("teacher")){
  53.    session.setAttribute("teacherID",login.getID() );
  54. //String questions=response.encodeUrl();
  55. response.sendRedirect("teacher/index-frames.jsp");
  56.   }
  57.   else if(logrole.equals("student")){
  58.    session.setAttribute("studentID",login.getID());
  59. //String questions=response.encodeUrl();
  60. response.sendRedirect("student/stu_test.jsp");
  61.  }
  62.  else if(logrole.equals("admin")){
  63.   session.setAttribute("adminID",login.getID() );
  64.   //String questions=response.encodeUrl();
  65. response.sendRedirect("administrator/admin.htm");
  66.  }
  67. }
  68. else{
  69.         out.print(message);
  70. //String loginpage=response.encodeUrl("login.jsp");
  71. //response.sendRedirect(loginpage);
  72. }
  73. }
  74. %>
  75. <html>
  76. <head>
  77. <title>
  78. CheckUser
  79. </title>
  80. </head>
  81. <body bgcolor="#ffffff">
  82. <SCRIPT language="javascript">
  83. alert("用户名或密码错误,请重新登录");
  84. window.location = "login.jsp";
  85. </SCRIPT>
  86. <h1>
  87. </h1>
  88. </body>
  89. </html>