分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

JSP内置对象阶段案例

发布时间:2023-09-06 01:45责任编辑:彭小芳关键词:内置对象

1.login2:

<%@ 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><base href="<%=basePath%>"><title>My JSP ‘login2.jsp‘ starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!-- ???<link rel="stylesheet" type="text/css" href="styles.css"> ???--></head><body> ???<form action="JSP/login2_temp.jsp" method="post"> ???????<table> ???????????<tr> ???????????????<td>用户名:</td> ???????????????<td><input type="text" name="username" /> ???????????????</td> ???????????</tr> ???????????<tr> ???????????????<td>密码</td> ???????????????<td><input type="text" name="password" /></td> ???????????</tr> ???????????<tr> ???????????<td><input ?type="submit"/></td></tr> ???????</table> ???</form></body></html>

2.login_temp:(注意判断是否为空再加入session中)

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><% ???String path = request.getContextPath(); ???String basePath = request.getScheme() + "://" ???????????+ request.getServerName() + ":" + request.getServerPort() ???????????+ path + "/"; ???String username = ""; ???String password = ""; ???username = request.getParameter("username"); ???password = request.getParameter("password"); ???if(username!=null){ ???????session.setAttribute("loginuser", username); ???} ???if("admin".equals(username)&&"admin".equals(password)){ ???????request.getRequestDispatcher("login2_success.jsp").forward(request, response); ???}else{ ???????response.sendRedirect("login2_failure.jsp"); ???} ???%>

3.login_seccess:

<%@ 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> ???<base href="<%=basePath%>"> ???????<title>My JSP ‘login2_success.jsp‘ starting page</title> ???????<meta http-equiv="pragma" content="no-cache"> ???<meta http-equiv="cache-control" content="no-cache"> ???<meta http-equiv="expires" content="0"> ???????<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> ???<meta http-equiv="description" content="This is my page"> ???<!-- ???<link rel="stylesheet" type="text/css" href="styles.css"> ???--> ?</head> ???<body> ??<h1>欢迎<%=session.getAttribute("loginuser") %> 登陆成功</h1> ?</body></html>

4.login2_failure:

<%@ 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> ???<base href="<%=basePath%>"> ???????<title>My JSP ‘login2_failure.jsp‘ starting page</title> ???????<meta http-equiv="pragma" content="no-cache"> ???<meta http-equiv="cache-control" content="no-cache"> ???<meta http-equiv="expires" content="0"> ???????<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> ???<meta http-equiv="description" content="This is my page"> ???<!-- ???<link rel="stylesheet" type="text/css" href="styles.css"> ???--> ?</head> ???<body> ???<h1>登陆失败,请检查您的用户名和密码</h1> ?</body></html>

JSP内置对象阶段案例

原文地址:https://www.cnblogs.com/sunxiaoyan/p/8543263.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved