JSP第五周-session
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% String pinglun=request.getParameter("pinglun"); session.setAttribute("e", pinglun); String c=(String)session.getAttribute("c"); String e=(String)session.getAttribute("e"); %> 用户: <%=c %> 评论:<%=e %> <br> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% String user1=request.getParameter("user1"); String mima1=request.getParameter("mima1"); session.setAttribute("a", user1); session.setAttribute("b", mima1); %> <form action="zhanghu.jsp"> 用户名:<input type="text" name="user2"> <br><br> 密 码:<input type="password" name="mima2"><br><br> <input type="submit" value="登录"> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% String user2=request.getParameter("user2"); String mima2=request.getParameter("mima2"); session.setAttribute("c", user2); session.setAttribute("d",mima2); String a=(String)session.getAttribute("a"); String b=(String)session.getAttribute("b"); String c=(String)session.getAttribute("c"); String d=(String)session.getAttribute("d"); %> <% if(a.equals(c)&&b.equals(d)){ if(c.equals("admin")){ out.println("后台操作页面"+"</br>"); out.print("管理员账号"+c+"登录密码"+d); }else{ request.getRequestDispatcher("xinwen.jsp").forward(request, response); } }else{ response.sendRedirect("zhuce.jsp"); } %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> 新闻直播间欢迎你!<br> <form action="xianshi.jsp"> <input type="text" name="pinglun"><input type="submit" value="提交评论"> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <% String pinglun=request.getParameter("pinglun"); session.setAttribute("e", pinglun); String c=(String)session.getAttribute("c"); String e=(String)session.getAttribute("e"); %> 用户: <%=c %> 评论:<%=e %> <br> </body> </html>