初学者jsp中登录界面判断是否登陆成功
2018-03-25 14:28
405 查看
首先先写登录界面:
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
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 'Login.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 align="center">用户登录</h1>
<form action="gain.jsp" method="post" name="loginForm">
<table align="center">
<tr>
<td>用户名:</td>
<td><input type="text" name="username" value="请你输入用户名"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td align="center"><input type="submit" onClick="validate" value="提交"></td>
</tr>
</table>
</form>
</body>
</html>
继续写出判断界面 首先给定一个用户名和密码进而进行判断
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
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 'gain.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>
<%
String name="张三";
String psw="123456";
request.setCharacterEncoding("gb2312");
String username=request.getParameter("username");
String password=request.getParameter("password");
if(username.equals(name)&&password.equals(psw)){
out.println("登录成功");
}else{
out.println("您的账号或者密码错误");
}
%>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
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 'Login.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 align="center">用户登录</h1>
<form action="gain.jsp" method="post" name="loginForm">
<table align="center">
<tr>
<td>用户名:</td>
<td><input type="text" name="username" value="请你输入用户名"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td align="center"><input type="submit" onClick="validate" value="提交"></td>
</tr>
</table>
</form>
</body>
</html>
继续写出判断界面 首先给定一个用户名和密码进而进行判断
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
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 'gain.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>
<%
String name="张三";
String psw="123456";
request.setCharacterEncoding("gb2312");
String username=request.getParameter("username");
String password=request.getParameter("password");
if(username.equals(name)&&password.equals(psw)){
out.println("登录成功");
}else{
out.println("您的账号或者密码错误");
}
%>
</body>
</html>
相关文章推荐
- JavaScript调用App原生代码(iOS、Android)通用解决方案 实际场景 场景:现在有一个H5活动页面,上面有一个登陆按钮,要求点击登陆按钮以后,唤出App内部的登录界面,当登录成功
- jsp 登陆成功后,显示登录的用户名
- jsp判断是否登录
- 判断checkbox是否被选中以及对jsp界面字段的长度进行限定
- 只有登录成功后,才能访问一些页面(2种方法:1.通过判断sesssion是否为空)2.过滤器Filter
- JSP JSTL界面是否包含的判断 fn:contains()函数
- Servlet 过滤器Filter判断用户是否登陆(jsp页面)
- 9-18 ASP第二讲实现数据的真实操作,从txt文件中读取进行校对,判断登陆是否成功
- web 开发,个人中心每个请求,判断用户是否登录,若没有登录,则跳转到登录页面,登录成功后返回之前页面
- Javaweb 判断是否登陆,否则则调回登陆界面,也就是session管理
- jsp+servlet判断是否登录以及登录是否失效
- 黑马程序员_控制台应用程序中判断用户是否登录成功
- 判断ftp是否登录成功
- 判断用户是否登录,如果登录了放行,否则跳转到登陆页面
- jsp判断用户是否登录
- WebBrowser判断登录成功-WebBrowser-404错误-500错误-屏蔽消息窗口-Webbrowser判断是否加载成功
- js判断登录界面用户名和密码是否为空
- 在主函数中提示用户输入用户名和密码。另写一方法来判断用户输入是否正确。该方法分别返回一个bool类型的登录结果和和一个string类型的登录信息。如登录成功,返回true及“登录成功”,若登录失败则返回false及“用户名错误”或“密码错误”(使用out参数)
- js登录界面判断输入的用户名和密码是否为空
- 熙熙-WebBrowser判断登录成功-WebBrowser-404错误-500错误-屏蔽消息窗口-Webbrowser判断是否加载成功