jsp 实现动态网页开发 登录小例子
2017-05-10 16:02
507 查看
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <form action="index.jsp" method="post"> 用户名: <input type="text" name="txtname" value="<%=request.getAttribute("name") %>"/> 密码: <input type="password" name="txtpwd"/> <input type="submit" value="提交"/> <br/> 爱好<input type="checkbox" name="hello" value="跑步"/> <input type="checkbox" name="hello" value="游泳"/> <input type="checkbox" name="hello" value="骑马"/> </form> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
String [] jihe=request.getParameterValues("hello");
String a="";
String b="";
String c="";
if(jihe!=null){
switch(jihe.length){
case 1:
a=jihe[0];
break;
case 2:
a=jihe[0];
b=jihe[1];
break;
case 3:
a=jihe[0];
b=jihe[1];
c=jihe[2];
break;
}
}
String name = request.getParameter("txtname");
System.out.println(name);
String pwd = request.getParameter("txtpwd");
if (name.equals("中文") && pwd.equals("1")) {
//保存作用域的值
request.setAttribute("name", name);
// request.setAttribute("jihe", jihe);
request.setAttribute("jihe0", a);
request.setAttribute("jihe1",b);
request.setAttribute("jihe2", c);
//跳转
request.getRequestDispatcher("/go.jsp").forward(request,
response);
}else{
//保存值
request.setAttribute("name", name);
// request.getRequestDispatcher("/regit.jsp").forward(request,response);
//重定义
response.sendRedirect("/Day_02shili/regit.jsp");
}
if(jihe!=null){
for(String item:jihe){
out.print(item+" ");
}
}
%>
输入错误页面
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
欢迎你 <%=request.getAttribute("name") %>
<%=request.getAttribute("jihe0") %>
<%=request.getAttribute("jihe1") %>
<%=request.getAttribute("jihe2") %>
</body>
</html>
相关文章推荐
- jsp 实现动态网页开发 登录小例子
- JSP+Servlet+JavaBean实现登录网页设计
- java jsp+servlet+mysql实现登录网页设计
- JSP+Servlet+JavaBean实现登录网页实例详解
- S2jsp 动态网页开发基础 web服务器
- 用JSP+Servlet+JavaBean模式实现一个简单的登录网页设计(JSP+Tomcat+MySQL)
- CMS内容管理系统开发- Java Web开发及发布实例(2)—使用JSP实现动态数据交互
- 组件开发小例子——网页右下角消息弹出框的实现
- JSP网页动态开发
- JSP系统开发学习之四关于用户登录界面的补充——通过request页面传值&wel.jsp的MVC的实现
- JSP的特点和其它动态网页开发技术比较
- 使用xml+jsp技术实现网页内容动态显示的方案
- android开发之扫描二维码实现网页登录
- JSP小例子——实现用户登录小例子(不涉及DB操作)
- appCan开发:oninput实现动态请求搜索功能例子
- JSP开发中在spring mvc项目中实现登录账号单浏览器登录
- JSP+Servlet+JavaBean实现登录网页实例详解
- jsp实现将动态网页转换成静态页面的方法
- 【JSP开发】有关session的登录注销的一个小例子
- 基于JSP+JavaBean的开发实例---登录模块的实现