关于JSP的一点疑问小结
来源:爱站网时间:2019-05-21编辑:网友分享
当我们写完编程之后会发现程序代码出现了一些小问题,但是自己却检查不出到底是哪里错了,因此而感到烦恼,那么我们现在一起去了解JSP的疑问小结,看看问题到底出在哪里。
当我们写完编程之后会发现程序代码出现了一些小问题,但是自己却检查不出到底是哪里错了,因此而感到烦恼,那么我们现在一起去了解JSP的疑问小结,看看问题到底出在哪里。
register.html部分:
复制代码 代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>register.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<br>
<form action="register.jsp" method = "Post" name = "frm">
用户名:<input type = "text" name = "in_username"><br>
密码:<input type = "password" name = "in_password"><br>
<input type = "submit" name = "submit" value = "提交">
</form>
</body>
</html>
register.jsp部分:
复制代码 代码如下:
<%@ page language="java" import = java.util.* pageEncoding="ISO-8859-1"%>
<%
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 'register.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">
<meta http-equiv = "content-type" content = "text/html;charset = gb2312">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<br>
<%! boolean isnotlogin = false;%>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
if(username == null || password == null)
{
response.sendRedirect("error.jsp");
return;
}
%>
<jsp:useBean id="person" scope = "page" class = "mypack.register">
<jsp:setProperty name = "person" property = "username" param = "username"/>
<jsp:setProperty name = "person" property = "pwd" param = "password"/>
</jsp:useBean>
<%
isnotlogin = person.judge();
if(!isnotlogin)
{
response.sendRedirect("error.jsp");
return;
}
else
{
session.setAttribute("username", request.getParameter("username"));
%>
<jsp:forward page = "sbmt">
<jsp:param name = "username" value = "<%=username%>"/>
</jsp:forward>
<%
}
%>
</body>
</html>
register.java(JavaBean)部分:
了解JSP的疑问小结之后,你看出问题所在了吗?如果你还想了解更多详细内容就请关注我们爱站技术频道吧。
上一篇:JavaBeans程序开发教程
下一篇:jsp网站如何换域名