package y2javaee.xmall.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import y2javaee.xmall.entity.*;
import y2javaee.xmall.operation.*;
import java.util.*;
public class SelectServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public SelectServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
response.setCharacterEncoding("gbk");
PrintWriter out = response.getWriter();
String action=request.getParameter("action");
String relation=request.getParameter("relation");
String id=request.getParameter("bookId");
Users user=new Users();
List bookList=new ArrayList();
List relationList=new ArrayList();
int count=0;
if(relation!=null&&!"".equals(relation))
count=Integer.parseInt(relation);
HttpSession ses=request.getSession();
user=(Users)ses.getAttribute("user");
if(user.getUserId()>0){
bookList=new BookBo().selectAllBook(user.getUserId());
ses.setAttribute("bookList", bookList);
}
if("login".equals(action))
{
response.sendRedirect("bookContent.jsp");
return;
}
if(count>0){
switch(count)
{
case 1:
relationList=new BookBo().bookByRelation(1, (List)ses.getAttribute("bookList"));
ses.setAttribute("relationList", relationList);
break;
case 2:
relationList=new BookBo().bookByRelation(2, (List)ses.getAttribute("bookList"));
ses.setAttribute("relationList", relationList);
break;
case 3:
relationList=new BookBo().bookByRelation(3, (List)ses.getAttribute("bookList"));
ses.setAttribute("relationList", relationList);
break;
case 4:
relationList=new BookBo().bookByRelation(4, (List)ses.getAttribute("bookList"));
ses.setAttribute("relationList", relationList);
break;
case 5:
relationList=new BookBo().bookByRelation(5, (List)ses.getAttribute("bookList"));
ses.setAttribute("relationList", relationList);
break;
case 6:
relationList=new BookBo().bookByRelation(6, (List)ses.getAttribute("bookList"));
ses.setAttribute("relationList", relationList);
break;
}
response.sendRedirect("bookContent.jsp");
}
if("delete".equals(action))
{
if(id!=null)
{
int i=new BookBo().deleteBook(id);
if(i>0)
out.print("<script>alert('删除成功!');location.replace('bookContent.jsp?action=selectAll');</script>");
else out.print("<script>alert('删除失败!');location.replace('bookContent.jsp?action=selectAll');</script>");
}
}
out.flush();
out.close();
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the POST method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
accp5.0y2项目实战-在线通讯录
共90个文件
gif:29个
jpg:20个
class:8个
需积分: 6 39 下载量 44 浏览量
2008-09-19
07:58:22
上传
评论
收藏 1.03MB RAR 举报
温馨提示
accp5.0y2项目实战-在线通讯录,仅供参考
资源推荐
资源详情
资源评论
收起资源包目录
addressBook.rar (90个子文件)
addressBook
.project 1KB
.mymetadata 306B
db
addressBook_data.mdf 3MB
addressBook_log.ldf 1024KB
addressBook.sql 2KB
WebRoot
WEB-INF
web.xml 2KB
lib
mssqlserver2.jar 402KB
classes
y2javaee
xmall
servlet
LoginServlet.class 3KB
SelectServlet.class 4KB
addServlet.class 3KB
common
DBConnection.class 1KB
operation
UserBo.class 2KB
BookBo.class 4KB
entity
Users.class 1KB
Book.class 2KB
index.jsp 11KB
META-INF
MANIFEST.MF 39B
addBook.jsp 14KB
CheckUser.jsp 922B
images
20054616104170383.gif 3KB
green.swf 4KB
2e-m-3d.gif 808B
2005431324010055.gif 3KB
liu.gif 1KB
e_an_1green~.swf 5KB
fan_1.swf 3KB
2e_bg.jpg 541B
33e_top11.jpg 6KB
e_an_1green.swf 4KB
200541116272355477.gif 2KB
you.swf 1KB
20054823114977499.gif 3KB
20054119481077038.gif 3KB
2e-m-yy.gif 888B
33e_left.jpg 3KB
200543128129181.gif 2KB
33e_down.jpg 3KB
notebook
dl.gif 1KB
t_bg.gif 383B
tl.gif 1KB
t_mr.gif 989B
Thumbs.db 19KB
dr.gif 1KB
m_bg_tr.gif 672B
d_bg.gif 579B
m_bg_tl.gif 232B
m_tr.gif 4KB
tr.gif 1KB
33e_right.jpg 3KB
e_copy.gif 296B
home.gif 1KB
xx1001.gif 3KB
down.jpg 3KB
20054823324343994.gif 3KB
2e-m-tp.gif 921B
Thumbs.db 69KB
2e_top.jpg 7KB
quan.jpg 2KB
green.jpg 22KB
2e_left.jpg 5KB
2e-m-xw.gif 921B
flower
tl.jpg 5KB
m_bg.jpg 4KB
tr.jpg 10KB
Thumbs.db 14KB
m_tl.jpg 16KB
bg.jpg 8KB
2005431332486265.gif 3KB
2e-m-dh.gif 1010B
2e_right.jpg 6KB
mystat.htm 310B
qi.gif 1KB
234x60.js 214B
enter.css 3KB
2e_down.jpg 7KB
33e_top1.jpg 2KB
22_top.jpg 2KB
top.jpg 2KB
shou.gif 1KB
bookContent.jsp 12KB
.myeclipse
jdbc驱动
mssqlserver2.jar 402KB
src
y2javaee
xmall
servlet
LoginServlet.java 3KB
SelectServlet.java 4KB
addServlet.java 4KB
common
DBConnection.java 1KB
operation
UserBo.java 1KB
BookBo.java 4KB
entity
Book.java 3KB
Users.java 1KB
.classpath 415B
共 90 条
- 1
资源评论
kinglwj
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功