ImageVerifierCode 换一换
格式:DOCX , 页数:10 ,大小:18.26KB ,
资源ID:18763243      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/18763243.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(J2ee注册的跳转和cookiesessionWord文档下载推荐.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

J2ee注册的跳转和cookiesessionWord文档下载推荐.docx

1、http:/www.w3.org/2001/XMLSchema-instance xmlns=/xmlns.jcp.org/xml/ns/javaee xsi:schemaLocation=/xmlns.jcp.org/xml/ns/javaee http:/xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd id=WebApp_ID version=3.1 libraryprojectwelcome-file-listwelcome-fileindex.htmlindex.htmindex.jspdefault.htmldefault.htmdefault

2、.jspfilter userFilterfilter-classcom.chinasofti.eec.filter.UserFilter/filterfilter-mappingurl-pattern/* /filter-mapping/web-appUserFilter.javapackage com.chinasofti.eec.filter;import java.io.IOException;import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;im

3、port javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class UserFilter implements Filter Override public void destroy() / TODO Auto-generated metho

4、d stub public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException HttpServletRequest req = (HttpServletRequest)arg0; HttpServletResponse resp = (HttpServletResponse)arg1; req.setCharacterEncoding(utf-8); resp.setCharacterEncoding( arg2.doFi

5、lter(arg0, arg1); public void init(FilterConfig arg0) throws ServletException 2 通过cookie来存储登录的次数Login.jsp% page language=java contentType=text/html; charset=utf-8 pageEncoding=%!DOCTYPE html PUBLIC -/W3C/DTD HTML 4.01 Transitional/EN /www.w3.org/TR/html4/loose.dtdhtmlheadmeta http-equiv=Content-Type

6、 content=titleInsert title here/headbodyform action=login method=postdiv align=center 用户名:input type=text name=userbr / 密 &码:passwordpwd radiodate value=0 checked=checked 每次登陆都需要1010天内3030天内/form/body/htmlLoginServlet.javapackage servlet;import javax.servlet.ServletContext;import javax.servlet.

7、annotation.WebServlet;import javax.servlet.http.HttpServlet;WebServlet(/login)public class LoginServlet extends HttpServlet protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException this.doPost(req, resp); protected void doPost(HttpServletRequest req

8、, HttpServletResponse resp) throws ServletException, IOException String btn = req.getParameter( String name = req.getParameter( String pwd = req.getParameter( if(.equals(btn) if(admin.equals(name)&.equals(pwd) ServletContext ctxt = getServletContext(); int count = 0; if(ctxt.getAttribute(count)=null

9、) count= 0; else count = Integer.parseInt(ctxt.getAttribute().toString(); count+; ctxt.setAttribute(, count); resp.sendRedirect(index.jsp Index.jsp charset=UTF-8leftfont color=blue访问次数 /font3 通过cookie来存储对用户密码进行存储内置对象来进行变量参数的赋值,通过req.getParament 与req.setAttribute(”key”,vlaue)righth1 red欢迎 % String us

10、ername = null; String pwd = null; Cookie c = request.getCookies(); if(c!=null& c.length!=0) for(Cookie co: c) if(co.getName().equals(username) /* 不同页面中传值的变量是的双引号是键值 */ username = co.getValue(); /* 同一个页面中传值的变量是自己本页面定义的变量不能直接拿 ,servlet中要通过req,resp来进行值的传递*/ else if(co.getName().equals(userpwd) pwd = co

11、.getValue(); if(username!=null & pwd !=null)% request.getRequestDispatcher(login?user=+username+pwd=+pwd+btn=登录).forward(request, response);import javax.servlet.http.Cookie; String timeLength = req.getParameter( /*name属性选择器中是页面上可以看见的键值变量*/ int days = 0; if(timeLength!=null) days = Integer.parseInt(timeLength); if(days! Cookie usernamecookie = new Cookie(,name); Cookie userpwd = new Cookie(,pwd); usernamecookie.setMaxAge(days*24*3600); userpwd.setMaxAge(days*24*36000); resp.addCookie(usernamecookie); resp.addCookie(userpwd); req.getSession().setAttribute(, name);

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1