
3个jsp文件,第一个是loginjsp,第二个是judgejsp,第三个是afterLoginjsp
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="javautil" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 401 Transitional//EN">
<html>
<head>
<title>登录页面</title>
</head>
<body>
<form name="loginForm" method="post" action="judgeUserjsp">
<table>
<tr>
<td>用户名:<input type="text" name="userName" id="userName"></td>
</tr>
<tr>
<td>密码:<input type="password" name="password" id="password"></td>
</tr>
<tr>
<td><input type="submit" value="登录" style="background-color:pink"> <input type="reset" value="重置" style="background-color:red"></td>
</tr>
</table>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="javautil" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 401 Transitional//EN">
<html>
<head>
<title>身份验证</title>
</head>
<body>
<%
requestsetCharacterEncoding("GB18030");
String name = requestgetParameter("userName");
String password = requestgetParameter("password");
if(nameequals("abc")&& passwordequals("123")) {
%>
<jsp:forward page="afterLoginjsp">
<jsp:param name="userName" value="<%=name%>"/>
</jsp:forward>
<%
}
else {
%>
<jsp:forward page="loginjsp"/>
<%
}
%>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 401 Transitional//EN">
<html>
<head>
<title>登录成功</title>
</head>
<body>
<%
requestsetCharacterEncoding("GB18030");
String name = requestgetParameter("userName");
outprintln("欢迎你:" + name);
%>
</body>
</html>
systemoutprintln("<table>");
for(i=0;i<3;i++)
{
systemoutprintln("<tr>");
for(j=0;j<3;j++)
{
systemoutprintln("<td>第"+i+"行第"+j+"列</td>");
}
systemoutprintln("</tr>");
}
systemoutprintln("</table>");
在一个页面上帮你搞定了。。。你自己看看然后再分把
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 401 Transitional//EN" ">
<table>
<%
for(int i=0;i<3;i++){//循环3次 每次输出一行
%><tr>
<%
for(int j=0;j<3;j++){//循环3次 每次输出一格 %>
<td>aaa</td>
<%}%>
</tr>
<%}%>
</table>
String path = requestgetContextPath();
File f = new File(path+"/abc");
if(!fexists()){
fmkdirs();
}
// fileName表示你创建的文件名;为txt类型;
String fileName="cbatxt";
File file = new File(f,fileName);
if(!fileexists()){
try {
filecreateNewFile();
} catch (IOException e) {
eprintStackTrace();
}
}
}
希望可以帮助到你,望采纳!
没明白你说什么意思?给你写一个吧indexjsp (首页)<%@ page language="java" import="javautil" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 401 Transitional//EN"><html> <head> <title>标题<title> </head> <body> <form action="resultjsp" method="post" onsubmit="return checkForm()">
<h2>用户登录</h2>
用户名:<input type="text" name="username" id="username" >
密码:<input type="password" name="password" id="password" />
<input type="submit" name="submit" value="登 录" />
</form> </body></html>resultjsp(获取表单提交的信息)<% //获取表单提交的参数requestgetParamter()获取 String name = requestgetParamter("username"); String password = requestgetParamter("password"); //进行处理 %> 就这样了,你要还不明白,可以加我QQ
以上就是关于编写用户注册于登录的JSP页面的全部程序代码全部的内容,包括:编写用户注册于登录的JSP页面的全部程序代码、编写一个jsp程序,通过for循环,在网页中输出一个3行3列的表格、用JSP编写一个猜数游戏程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)