欢迎来到天天文库
浏览记录
ID:39550172
大小:207.50 KB
页数:21页
时间:2019-07-06
《JSP学习笔记-1》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Connectioncon;Statementstmt;ResultSetrs;Class.forName=("oracle.jdbc.driver.OracleDriver");con=DriverManager.getConnection("连接字符串","用户名","密码");stmt=con.createStatement();Stringstr="select*fromstudent";rs=stmt.executeQuery(str);while(rs.next()){stmt.getString().rs.setString();}2、ipt"type="">functioncheckUserInfo(){if(document.username.value==""){alert("用户名不能为空");returnfalse;}}登录处理页面<%request.setCharacterEncoding("UTF-8");Stringname=request.getParameter("userName");Stringpwd=request.getParame3、ter("pwd");if(name.equals("sa")&&pwd.equals("sa")){response.sendRedirect("welcome.jsp");}%>用户登录页面用户名:密码:欢迎页面<%Stringname=request.getParameter("us4、erName");%>欢迎<%=name%>进入本页面登录页面处理<%request.setCharacterEncoding("UTF-8");Stringname=request.getParameter("userName");Stringpwd=requset.getParameter("pwd");if(name.equels("sa")&&pwd.equels("sa")){request.getRequestDispatcher("welcome.jsp").foeward(request,response);}%>第4章cookie的作用1.对待定对象的追踪,如访问者的访问次数5、,最后访问时间,路径等。2.统计网页浏览次数。3.在cookie有效期内,记录用户登录信息。4.实现各种个性化服务,如针对不同用户喜好以不同的风格展示不同的内容。在JSP中使用COOKIE1.使用page指令导入类javax.servlet.http.cookie<%@pageimport="javax.servllet.http.cookie"%>2.创建cookie对象CookienewCookie=newCookie(Stringkey,Objectvalue);3.写入cookieresponse.addCookie(newCookie);<%response.addCookie(ne6、wCookie("username","Jack"));response.addCookie(newCookie("password","123465"));response.getRequestDispatcher("look.jsp").forward(request,response);%>4.读取cookie案例:login.jsp用户登录页面用户名:密&nsbp码:7、ame="pwd">doLogin.jsp登录处理页面<%request.setCharacterEncoding("UTF-8");Stringname=request.getParameter("username");Stringpwd=request.getParameter("pwd");if("sa".equal
2、ipt"type="">functioncheckUserInfo(){if(document.username.value==""){alert("用户名不能为空");returnfalse;}}登录处理页面<%request.setCharacterEncoding("UTF-8");Stringname=request.getParameter("userName");Stringpwd=request.getParame
3、ter("pwd");if(name.equals("sa")&&pwd.equals("sa")){response.sendRedirect("welcome.jsp");}%>用户登录页面用户名:密码:欢迎页面<%Stringname=request.getParameter("us
4、erName");%>欢迎<%=name%>进入本页面登录页面处理<%request.setCharacterEncoding("UTF-8");Stringname=request.getParameter("userName");Stringpwd=requset.getParameter("pwd");if(name.equels("sa")&&pwd.equels("sa")){request.getRequestDispatcher("welcome.jsp").foeward(request,response);}%>第4章cookie的作用1.对待定对象的追踪,如访问者的访问次数
5、,最后访问时间,路径等。2.统计网页浏览次数。3.在cookie有效期内,记录用户登录信息。4.实现各种个性化服务,如针对不同用户喜好以不同的风格展示不同的内容。在JSP中使用COOKIE1.使用page指令导入类javax.servlet.http.cookie<%@pageimport="javax.servllet.http.cookie"%>2.创建cookie对象CookienewCookie=newCookie(Stringkey,Objectvalue);3.写入cookieresponse.addCookie(newCookie);<%response.addCookie(ne
6、wCookie("username","Jack"));response.addCookie(newCookie("password","123465"));response.getRequestDispatcher("look.jsp").forward(request,response);%>4.读取cookie案例:login.jsp用户登录页面用户名:密&nsbp码:7、ame="pwd">doLogin.jsp登录处理页面<%request.setCharacterEncoding("UTF-8");Stringname=request.getParameter("username");Stringpwd=request.getParameter("pwd");if("sa".equal
7、ame="pwd">doLogin.jsp登录处理页面<%request.setCharacterEncoding("UTF-8");Stringname=request.getParameter("username");Stringpwd=request.getParameter("pwd");if("sa".equal
此文档下载收益归作者所有