jsp第八周作业
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML > <html> <head> <title>My JSP 'index.jsp' starting page</title> </head> <body> <% session.invalidate(); response.sendRedirect("login.jsp"); %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML > <html> <head> <title>My JSP 'index.jsp' starting page</title> </head> <body> <script> function yz() { if (form.user.value == "") { alert('用户名不能为空'); return; } if (form.password.value == "") { alert('密码不能为空'); return; } form.submit(); } </script> <form action="index.jsp" method="post" name="form"> <table> <tr> <td>用户名:</td> <td><input type="text" name="user"></td> </tr> <tr> <td>密码:</td> <td><input type="password" name="password"></td> </tr> <tr> <td><input type="button" value="登录" onclick="yz()"></td> </tr> </table> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML > <html> <head> <title>My JSP 'index.jsp' starting page</title> </head> <body> <% String user = (String) session.getAttribute("user"); if (user == null) { response.sendRedirect("login.jsp"); } %> 欢迎:<%=user%> <a href="out.jsp">退出登录</a> <form action="cart.jsp" method="post"> 商品:<br> <br> 衣服<input type="checkbox" name="item" value="yifu">加入购物车 <br> 裤子<input type="checkbox" name="item" value="kuzi">加入购物车 <br> 鞋子<input type="checkbox" name="item" value="xiezi">加入购物车<br><br> <input type="submit" value="加入购物车"> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML > <html> <head> <title>显示购物车</title> </head> <body> <% request.setCharacterEncoding("utf-8"); String[] sp = request.getParameterValues("sp"); for (int i = 0; sp != null && i < sp.length; i++) { out.print(sp[i] + "<br>"); } %> </body> </html>
posted on 2022-04-26 13:51 chenyulin11 阅读(6) 评论(0) 编辑 收藏 举报