- 浏览: 50391 次
- 性别:
- 来自: 合肥
文章分类
最新评论
首先是登陆界面,其中有mes_zh等国际化 这个不重要
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<style>
body{
fontsize:12px;
}
#keyword,#iskey{
color:red;
}
</style>
<html>
<head>
</head>
<body>
<%-- ${cookie}--%>
<fmt:setBundle basename="mes"/>
<span style="color:red;fontSize:15px">${LogFail}</span>
<form action="login.do" method="post">
<fmt:message key="username"></fmt:message><input type="text" name="username"/>
<fmt:message key="password"></fmt:message></fmt><input type="password" name="password"/>
<input style="margin-left: 50px"type="checkbox" name="remeber" value="yes"/>
<span style="color:red">是否记住密码?</span><br/>
<input style="margin-top:20px" type="submit" value="<fmt:message key="login"></fmt:message>"/>
</form>
<table>
<tr><th colspan="6"><fmt:message key="key"></fmt:message><span id="keyword">${keyWord}</span></th></tr>
<tr><th><fmt:message key="id"></fmt:message></th><th><fmt:message key="name"></fmt:message></th>
<th><fmt:message key="address"></fmt:message></th><th><fmt:message key="phone"></fmt:message></th>
<th><fmt:message key="email"></fmt:message></th><th><fmt:message key="sex"></fmt:message></th></tr>
<c:forEach items="${contacts}" var="con">
<tr><td>${con.id}</td><td id="iskey">${con.name}</td><td>${con.address}</td><td>${con.phone }</td><td>${con.email}</td><td>${con.sex }</th></tr>
</c:forEach>
</table>
</body>
</html>
接下来是上面post请求的servlet类
package com.ourchr.addressbook.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import bo.UserBO;
import entity.User;
public class LoginServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Cookie[] cookies = request.getCookies();
Cookie cookie = null;
String username = null;
String password = null;
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
cookie = cookies[i];
System.out.println(cookie.getName()+"++++"+cookie.getValue());
if (cookie.getName().equals("username")){
username = cookie.getValue();
}
if(cookie.getName().equals("password")){
password = cookie.getValue();
}
}
}
UserBO userBO =new UserBO();
User user = userBO.login(username, password);
if(user==null){
request.getRequestDispatcher("/login.jsp").forward(request, response);
}else{
request.getSession().setAttribute("user", user);
String url = (String) request.getAttribute("requestURL");
response.sendRedirect(url);
return;
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String username = request.getParameter("username");
String password = request.getParameter("password");
String remeber = request.getParameter("remeber");
System.out.println(username+"==="+password+"==="+remeber);
UserBO userBO = new UserBO();
User user = userBO.login(username, password);
if (user == null) {
request.setAttribute("LogFail", "用户名或密码错误,请重新登录");
request.getRequestDispatcher("/login.jsp").forward(request,
response);
} else {
request.getSession().setAttribute("user", user);
if (remeber.equals("yes")) {
Cookie cookie = new Cookie("username", username);
cookie.setMaxAge(3600 * 24 * 30);
response.addCookie(cookie);
cookie= new Cookie("password", password);
cookie.setMaxAge(3600 * 24 * 30);
response.addCookie(cookie);
request.getSession().setAttribute("user", user);
System.out.println(request.getCookies().length+"------");
}
request.getRequestDispatcher("/choseItem.jsp").forward(request,
response);
}
}
}
剩下的都是容易实现的了
我把该登陆用户的功能分为两部分
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="h" tagdir="/WEB-INF/tags" %>
<style>
body{
fontsize;12px;
}
#link{
width:100px;
height:50px;
}
</style>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<h:ckeckLogin></h:ckeckLogin>
<div style="color:blue;fontsize;15px;margin-bottom:50px">${LogSuccess}</div>
<div id="link">
<a href="addContact.jsp" id="addLink">增加联系人</a>
</div>
<div id="link">
<a href="findContact.jsp" id="findLink">查找联系人</a>
</div>
</body>
</html>
那接下来增加和查找也顺便写下吧
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
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 'checkLogin.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">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<hr/>
添加失败的用户信息: <c:out value="${Conexception}"></c:out>
<hr/>
<form action="doAddContact.jsp" method="post">
<table>
<tr>
<td>姓名:</td><td><input type="text" name="username"/></td>
</tr>
<tr>
<td>手机:</td><td><input type="text" name="phone"/></td>
</tr>
<tr>
<td>Email:</td><td><input type="text" name="email"/></td>
</tr>
<tr>
<td>地址:</td><td><input type="text" name="address"/></td>
</tr>
<tr>
<td>性别:</td>
<td>
男<input type="radio" name="sex" value="male" ckecked="checked" >
女<input type="radio" name="sex" value="female" >
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="提交"/><input type="reset" value="重置"/>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ page language="java" import="java.util.*,com.ourchr.assdressbook.entity.*,entity.*,com.ourchr.addressbook.bo.*,com.ourchr.addressbook.exception.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
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 'doAddContact.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">
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
String name =request.getParameter("username");
String phone =request.getParameter("phone");
String email = request.getParameter("email");
String address = request.getParameter("address");
String sex = request.getParameter("sex");
Contact contact = new Contact();
contact.setName(name);
contact.setPhone(phone);
contact.setEmail(email);
contact.setAddress(address);
contact.setSex(sex);
contact.setOwner((User)session.getAttribute("user"));
session.setAttribute("contact",contact);
ContactBO contactBO = new ContactBO();
%>
<c:catch var="ContactExistException">
<%
contactBO.addContact(contact);
%>
</c:catch>
<c:if test="${not empty ContactExistException}">
<c:set var="Conexception" value="${ContactExistException.message}" scope="request"></c:set>
<jsp:forward page="/addContact.jsp"></jsp:forward>
</c:if>
<c:if test="${empty ContactExistException}">
<jsp:forward page="/showContact.jsp"></jsp:forward>
</c:if>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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>
</head>
<body>
<h1>给用户提供查询联系人:</h1>
<form action="doFindContact.jsp" method="post">
<input type="text" name="conName"/>
<input type="submit">
</form>
</body>
</html>
<%@ page language="java" import="java.util.*,entity.*,com.ourchr.assdressbook.entity.*,com.ourchr.addressbook.bo.ContactBO" pageEncoding="UTF-8"%>
<%
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>
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
String conNameIndex =request.getParameter("conName");
User owner= (User)session.getAttribute("user");
ContactBO contactBO = new ContactBO();
List<Contact> contacts=contactBO.findContacts(owner,conNameIndex);
request.setAttribute("keyWord",conNameIndex);
request.setAttribute("contacts",contacts);
%>
<jsp:forward page="login.jsp"></jsp:forward>
</body>
</html>
那几本上都差不多了吧
还有一个标签
<%@ tag pageEncoding="utf-8" body-content="scriptless" import="entity.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
User user = (User)session.getAttribute("user");
if(user == null){
String url = request.getRequestURL().toString();
request.setAttribute("requestURL",url);
request.getRequestDispatcher("login.do").forward(request,response);
}
%>
完成!
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<style>
body{
fontsize:12px;
}
#keyword,#iskey{
color:red;
}
</style>
<html>
<head>
</head>
<body>
<%-- ${cookie}--%>
<fmt:setBundle basename="mes"/>
<span style="color:red;fontSize:15px">${LogFail}</span>
<form action="login.do" method="post">
<fmt:message key="username"></fmt:message><input type="text" name="username"/>
<fmt:message key="password"></fmt:message></fmt><input type="password" name="password"/>
<input style="margin-left: 50px"type="checkbox" name="remeber" value="yes"/>
<span style="color:red">是否记住密码?</span><br/>
<input style="margin-top:20px" type="submit" value="<fmt:message key="login"></fmt:message>"/>
</form>
<table>
<tr><th colspan="6"><fmt:message key="key"></fmt:message><span id="keyword">${keyWord}</span></th></tr>
<tr><th><fmt:message key="id"></fmt:message></th><th><fmt:message key="name"></fmt:message></th>
<th><fmt:message key="address"></fmt:message></th><th><fmt:message key="phone"></fmt:message></th>
<th><fmt:message key="email"></fmt:message></th><th><fmt:message key="sex"></fmt:message></th></tr>
<c:forEach items="${contacts}" var="con">
<tr><td>${con.id}</td><td id="iskey">${con.name}</td><td>${con.address}</td><td>${con.phone }</td><td>${con.email}</td><td>${con.sex }</th></tr>
</c:forEach>
</table>
</body>
</html>
接下来是上面post请求的servlet类
package com.ourchr.addressbook.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import bo.UserBO;
import entity.User;
public class LoginServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Cookie[] cookies = request.getCookies();
Cookie cookie = null;
String username = null;
String password = null;
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
cookie = cookies[i];
System.out.println(cookie.getName()+"++++"+cookie.getValue());
if (cookie.getName().equals("username")){
username = cookie.getValue();
}
if(cookie.getName().equals("password")){
password = cookie.getValue();
}
}
}
UserBO userBO =new UserBO();
User user = userBO.login(username, password);
if(user==null){
request.getRequestDispatcher("/login.jsp").forward(request, response);
}else{
request.getSession().setAttribute("user", user);
String url = (String) request.getAttribute("requestURL");
response.sendRedirect(url);
return;
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html");
String username = request.getParameter("username");
String password = request.getParameter("password");
String remeber = request.getParameter("remeber");
System.out.println(username+"==="+password+"==="+remeber);
UserBO userBO = new UserBO();
User user = userBO.login(username, password);
if (user == null) {
request.setAttribute("LogFail", "用户名或密码错误,请重新登录");
request.getRequestDispatcher("/login.jsp").forward(request,
response);
} else {
request.getSession().setAttribute("user", user);
if (remeber.equals("yes")) {
Cookie cookie = new Cookie("username", username);
cookie.setMaxAge(3600 * 24 * 30);
response.addCookie(cookie);
cookie= new Cookie("password", password);
cookie.setMaxAge(3600 * 24 * 30);
response.addCookie(cookie);
request.getSession().setAttribute("user", user);
System.out.println(request.getCookies().length+"------");
}
request.getRequestDispatcher("/choseItem.jsp").forward(request,
response);
}
}
}
剩下的都是容易实现的了
我把该登陆用户的功能分为两部分
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="h" tagdir="/WEB-INF/tags" %>
<style>
body{
fontsize;12px;
}
#link{
width:100px;
height:50px;
}
</style>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<h:ckeckLogin></h:ckeckLogin>
<div style="color:blue;fontsize;15px;margin-bottom:50px">${LogSuccess}</div>
<div id="link">
<a href="addContact.jsp" id="addLink">增加联系人</a>
</div>
<div id="link">
<a href="findContact.jsp" id="findLink">查找联系人</a>
</div>
</body>
</html>
那接下来增加和查找也顺便写下吧
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
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 'checkLogin.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">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<hr/>
添加失败的用户信息: <c:out value="${Conexception}"></c:out>
<hr/>
<form action="doAddContact.jsp" method="post">
<table>
<tr>
<td>姓名:</td><td><input type="text" name="username"/></td>
</tr>
<tr>
<td>手机:</td><td><input type="text" name="phone"/></td>
</tr>
<tr>
<td>Email:</td><td><input type="text" name="email"/></td>
</tr>
<tr>
<td>地址:</td><td><input type="text" name="address"/></td>
</tr>
<tr>
<td>性别:</td>
<td>
男<input type="radio" name="sex" value="male" ckecked="checked" >
女<input type="radio" name="sex" value="female" >
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="提交"/><input type="reset" value="重置"/>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ page language="java" import="java.util.*,com.ourchr.assdressbook.entity.*,entity.*,com.ourchr.addressbook.bo.*,com.ourchr.addressbook.exception.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
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 'doAddContact.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">
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
String name =request.getParameter("username");
String phone =request.getParameter("phone");
String email = request.getParameter("email");
String address = request.getParameter("address");
String sex = request.getParameter("sex");
Contact contact = new Contact();
contact.setName(name);
contact.setPhone(phone);
contact.setEmail(email);
contact.setAddress(address);
contact.setSex(sex);
contact.setOwner((User)session.getAttribute("user"));
session.setAttribute("contact",contact);
ContactBO contactBO = new ContactBO();
%>
<c:catch var="ContactExistException">
<%
contactBO.addContact(contact);
%>
</c:catch>
<c:if test="${not empty ContactExistException}">
<c:set var="Conexception" value="${ContactExistException.message}" scope="request"></c:set>
<jsp:forward page="/addContact.jsp"></jsp:forward>
</c:if>
<c:if test="${empty ContactExistException}">
<jsp:forward page="/showContact.jsp"></jsp:forward>
</c:if>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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>
</head>
<body>
<h1>给用户提供查询联系人:</h1>
<form action="doFindContact.jsp" method="post">
<input type="text" name="conName"/>
<input type="submit">
</form>
</body>
</html>
<%@ page language="java" import="java.util.*,entity.*,com.ourchr.assdressbook.entity.*,com.ourchr.addressbook.bo.ContactBO" pageEncoding="UTF-8"%>
<%
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>
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
String conNameIndex =request.getParameter("conName");
User owner= (User)session.getAttribute("user");
ContactBO contactBO = new ContactBO();
List<Contact> contacts=contactBO.findContacts(owner,conNameIndex);
request.setAttribute("keyWord",conNameIndex);
request.setAttribute("contacts",contacts);
%>
<jsp:forward page="login.jsp"></jsp:forward>
</body>
</html>
那几本上都差不多了吧
还有一个标签
<%@ tag pageEncoding="utf-8" body-content="scriptless" import="entity.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
User user = (User)session.getAttribute("user");
if(user == null){
String url = request.getRequestURL().toString();
request.setAttribute("requestURL",url);
request.getRequestDispatcher("login.do").forward(request,response);
}
%>
完成!
发表评论
-
oracle 笔记下
2011-07-06 18:17 785建立表空间:建立表空 ... -
oracle 学习笔记上
2011-06-20 19:00 10851.oracle 安装完成后,会 ... -
jquery 对select中的option操作
2011-06-15 16:28 6260Jquery的功能很强大,下面 ... -
MySQL实现分页技术
2011-06-09 08:29 901先给出servlet package com.ourchr.s ... -
java学习日记(线程)
2011-05-18 18:38 812java学习日记(线程) 一 ... -
Java Servlet和JSP 处理Cookie
2011-05-18 13:28 19499.1 Cookie概述 Cookie是服务器发送给浏 ... -
简单的qq实现
2011-05-17 18:42 731很好用 简洁 -
简单的日历控件
2011-05-17 18:40 794package Exception; import java ... -
完整的JDBC 简单列子
2011-05-17 18:38 688package dao; import java.sql.Co ... -
jsp jstl 标签3
2011-05-13 17:38 696<c:import> 作用:导入一个url的资源, ... -
jsp jstl 标签2
2011-05-13 17:38 741c:forEach 用于循环的<c:forEach&g ... -
jsp jstl 标签1
2011-05-13 17:36 1190一、引入包: jstl.jar (1 ... -
js 中this用发小结
2011-03-09 09:19 701js中this的总结 在面向对 ... -
js 正则表达式
2011-02-24 15:12 631js正则表达式 exec 方法 用正则表达式模式在字符串中运 ... -
WEB innerHTML中div 和span
2011-02-24 13:58 1240使用innerHTML属性来控制DIV和SPAN<$lo ... -
Myeclipse 快捷键打总结
2011-01-08 13:01 726xml、jsp、jsf、js等等,我们没有必要全部都去自动校验 ... -
java基础知识
2011-01-07 17:35 693 -
java文件夹之间的复制
2011-01-06 14:58 655package Exception; import java. ...
相关推荐
在本文中,我们将深入探讨如何使用Servlet和JSP来实现一个简单的购物车功能,并结合Cookie技术来存储用户的选择。Servlet是Java服务器端编程的核心技术,用于处理HTTP请求和响应;JSP(JavaServer Pages)是一种动态...
- 掌握通过Servlet进行会话跟踪和管理,了解Cookie和Session的使用方法。 - 探索Servlet的过滤器(Filter)和监听器(Listener)机制,以及它们在应用中的实际应用场景。 2. JSP技术的原理和应用 - JSP是一种...
9. **Session和Cookie**:在Servlet和JSP中,session用于存储用户会话信息,cookie则常用于持久化用户状态或实现无状态会话。 10. **MVC框架与Servlet/JSP结合**:Spring MVC、Struts2等框架整合了Servlet和JSP,...
Servlet和JSP是Java Web开发中的核心技术,它们用于构建动态、交互式的Web应用程序。本学习指南的源代码提供了丰富的示例,帮助开发者深入理解这两门技术。以下是对这两个概念的详细解析。 **Servlet概述** Servlet...
HTTP请求报头 5、服务器响应的生成:HTTP状态代码 6、服务器响应的生成: HTTP响应报头 7、cookie管理 8、会话跟踪 9、JSP技术概述 10、JDBC 11、控制所生成的servlet 的结构:JSP page指令...
HTTP请求报头 5、服务器响应的生成:HTTP状态代码 6、服务器响应的生成: HTTP响应报头 7、cookie管理 8、会话跟踪 9、JSP技术概述 10、JDBC 11、控制所生成的servlet 的结构:JSP page指令...
Servlet和JSP是Java Web开发中的重要组成部分,它们在构建动态网页和Web应用程序中起着关键作用。本书《Servlet与JSP核心编程(第二版)卷二》的源代码集合,为读者提供了丰富的实践素材,有助于深入理解这两种技术...
11. **Session和Cookie**:Servlet和JSP可以利用Session跟踪用户会话,存储用户信息;Cookie则用于在客户端保存数据,实现会话持久化或个性化设置。 12. **过滤器(Filter)和监听器(Listener)**:过滤器可以在...
【Servlet和JSP基础】 Servlet和JSP是Java Web开发中的核心技术,用于构建动态网站。Servlet是Java编写的服务器端程序,主要功能是接收并处理客户端(如浏览器)的请求,然后返回响应。JSP(JavaServer Pages)则是...
本示例探讨了如何在Servlet中使用Cookie技术来实现用户登录信息的持久化存储,以便用户在再次访问网站时无需重复登录。下面将详细解释相关知识点。 1. **Servlet**:Servlet是Java平台上的一个标准接口,它允许Java...
Servlet和JSP(JavaServer Pages)是Java开发语言在Web应用中的两个核心组件,它们主要用于构建动态、交互式的Web应用程序。这篇文档的翻译是对外文文献《Servlet和JSP技术简介》的概述,作者Marty Hall和Larry ...
### Servlet与JSP核心编程第二版知识点概览 #### 一、Servlet基础知识 - **Servlet概念**:Servlet是一种运行在服务器端的小程序,主要用于处理客户端请求并生成动态Web页面或数据。Servlet是Java Web开发的基础...
### Servlet与JSP与Filter的使用详解 #### 一、Servlet与JSP的基本概念 Servlet是一种Java技术,用于创建动态Web应用程序。它本质上是一个Java类,由Web服务器或应用服务器加载,以响应客户端请求。Servlet可以...
《基于JavaBean、Servlet与JSP的网上购物系统——学校实训项目详解》 在IT行业中,Web开发是一项至关重要的技能,而Java技术栈是其中的主流之一。本实训项目“学校实训JSP项目-网上购物系统”正是一个典型的应用...
### Servlet与JSP详解 #### 一、Servlet基础概述 **Servlet** 是Java Web开发的基础技术之一,主要用于处理客户端的HTTP请求,并返回响应结果。它是一种服务器端的Java应用程序,可以扩展服务器的功能。 ##### ...
【Servlet和JSP入门教程】 本教程主要针对的是Servlet 2.4和JSP 2.0,这两个技术是构建Java Web应用的关键组件。Servlet是一种Java编程接口,用于扩展服务器的功能,而JSP(JavaServer Pages)则是一种动态网页技术...
Servlet和JSP(JavaServer Pages)是Java Web开发中的核心技术,用于构建动态网站和Web应用程序。Servlet是Java编程语言中的一个接口,它扩展了服务器的功能,允许开发人员处理HTTP请求和响应。JSP则是一种视图技术...
在IT行业中,尤其是在Web开发领域,Cookie、Servlet和JSP是三个非常重要的概念。这篇讨论主要聚焦于如何使用这些技术来实现用户登录并记录登录次数的功能。以下是对这些知识点的详细解释: **Cookie**: Cookie是一...
### Servlet和JSP技术概述及应用 #### 一、引言 随着互联网技术的发展,Web应用的需求日益增加,为了提供高效、稳定且可扩展的服务,Servlet 和 JSP 成为了解决这一需求的关键技术之一。本文将详细介绍 Servlet 和...