jsp第11次作业
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'register.jsp' starting page</title> </head> <body> <script type="text/javascript"> function validate(){ if(registerForm.uname.value==""){ alert("账号不能为空!"); return; } if(registerForm.upwd.value==""){ alert("密码不能为空!"); return; } registerForm.submit(); } </script> <form name="registerForm" action="doreg.jsp" method="post"> 用户名:<input type="text" name="uname"><br> 密 码: <input type="password" name="upwd"> <br> <input type="submit" value="注册"> <a href="denglu.jsp">登录</a> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'dologin.jsp' starting page</title> </head> <body> <% request.setCharacterEncoding("utf-8"); String uname = request.getParameter("uname"); String upwd = request.getParameter("upwd"); UserDao ud = new UserDao(); if (ud.login(uname, upwd)) { session.setAttribute("uname",uname); request.getRequestDispatcher("main.jsp").forward( request,response); } else { out.print("登录失败,即将跳回登录页......"); response.setHeader("refresh", "3;url=denglu.jsp"); } %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@page import="com.gd.dao.UsersDao"%> <%@page import="com.gd.dao.MsgDao"%> <% request.setCharacterEncoding("utf-8"); String uname=request.getParameter("uname"); String upwd=request.getParameter("upwd"); UsersDao ud=new UsersDao(); MsgDao md=new MsgDao(); if(ud.register(uname, upwd)>0){ session.setAttribute("uname", uname); request.getRequestDispatcher("dengli.jsp").forward(request,response); }else{ out.print("注册失败"); response.setHeader("refresh","5;url=register.jsp"); } %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'main.jsp' starting page</title> </head> <body > <% String uname = (String) session.getAttribute("uname"); %> 欢迎你<% out.print(uname); %>使用邮箱 <hr> <table border="2px solid black"> <tr> <td>id</td> <td>发件人</td> <td>标题</td> <td>内容</td> <td>已读未读状态</td> <td>收件人</td> <td>发送时间</td> </tr> <% MsgDao md = new MsgDao(); List<Msg> list=md.getMailByReceiver(uname); for (Msg m : list) { %> <tr> <td><%=m.getMsgid()%></td> <td><%=m.getUsername()%></td> <td><%=m.getTitle()%></td> <td><%=m.getMsgcontent()%></td> <td> <% int state = Integer.parseInt(m.getState()); if (state == 1) { %> <img src="image/yidu.png"> <% ; } else { %> <img src="image/weidu.png"> <% ; } %> </td> <td><%=m.getSendto()%></td> <td><%=m.getSetMsg_create_date()%></td> </tr> <% } %> </table> </body> </html>
<%@page import="com.gd.dao.UsersDao"%> <%@page import="com.gd.dao.MsgDao"%> <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% request.setCharacterEncoding("utf-8"); String uname = request.getParameter("uname"); String upwd = request.getParameter("upwd"); UsersDao ud=new UsersDao(); MsgDao md=new MsgDao(); if(ud.login(uname, upwd)){ session.setAttribute("uname", uname); request.getRequestDispatcher("main.jsp").forward(request, response); }else{ out.print("登陆失败,即将跳回登陆页....."); response.setHeader("refresh", "5;url=denglu.jsp"); } %>