package com.wsr.shoppingonline.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import com.wsr.shoppingonline.biz.*;
import com.wsr.shoppingonline.biz.impl.*;
import com.wsr.shoppingonline.pojo.*;
public class ActionServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String path = req.getServletPath();
path = path.substring(0, path.lastIndexOf("."));
if (path.equals("/shopping/login")) {
login(req, res);
} else if (path.equals("/shopping/register")) {
register(req, res);
} else if (path.equals("/shopping/findinfo")) {
findInfo(req, res);
} else if (path.equals("/shopping/modify")) {
modify(req, res);
} else if (path.equals("/shopping/remove")) {
remove(req, res);
} else if (path.equals("/shopping/gostore")) {
goStore(req, res);
} else if (path.equals("/shopping/lookcart")) {
lookCart(req, res);
} else if (path.equals("/shopping/quit")) {
quit(req, res);
} else if (path.equals("/shopping/findbook")) {
findBook(req, res);
} else if (path.equals("/shopping/findhomedevice")) {
findHomeDevice(req, res);
} else if (path.equals("/shopping/findmobilephone")) {
findMobilePhone(req, res);
} else if (path.equals("/shopping/findcomputer")) {
findComputer(req, res);
} else if (path.equals("/shopping/search")) {
search(req, res);
} else if (path.equals("/shopping/index/findbook")) {
indexFindBook(req, res);
} else if (path.equals("/shopping/index/findhomedevice")) {
indexFindHomeDevice(req, res);
} else if (path.equals("/shopping/index/findmobilephone")) {
indexFindMobilephone(req, res);
} else if (path.equals("/shopping/index/findcomputer")) {
indexFindComputer(req, res);
} else if (path.equals("/shopping/index/search")) {
indexSearch(req, res);
} else if (path.equals("/shopping/index")) {
findAllProducts(req, res);
} else if (path.equals("/shopping/find")) {
find(req, res);
} else if (path.equals("/shopping/addtocart")) {
addToCart(req, res);
} else if (path.equals("/shopping/cleancart")) {
cleanCart(req, res);
} else if (path.equals("/shopping/deletecartitem")) {
deleteCartItem(req, res);
} else if (path.equals("/shopping/updatecount")) {
updateCount(req, res);
} else if (path.equals("/shopping/buy")) {
buy(req, res);
} else if (path.equals("/shopping/submitorder")) {
submitOrder(req, res);
} else if (path.equals("/shopping/lookorder")) {
lookOrder(req, res);
} else if (path.equals("/shopping/orderdetail")) {
orderDetail(req, res);
}else if (path.equals("/shopping/tomodify")) {
toModify(req, res);
}
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doGet(req, res);
}
/*
* 用户登录
*/
private void login(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
UserService us = new UserServiceImpl();
us.login(req, res);
}
/*
* 用户注册
*/
private void register(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
UserService us = new UserServiceImpl();
us.register(req, res);
}
/*
* 查看个人注册信息
*/
private void findInfo(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
try {
UserService userService = new UserServiceImpl();
List<User> users = userService.findInfo();
req.setAttribute("users", users);
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("/userinfo.jsp");
rd.forward(req, res);
} catch (Exception e) {
e.printStackTrace();
}
}
/*
* 修改个人信息
*/
private void modify(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
UserService us = new UserServiceImpl();
us.modify(req, res);
}
/*
* 删除个人信息
*/
private void remove(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
UserService us = new UserServiceImpl();
us.delete(req, res);
}
/*
* 去购物商城
*/
private void goStore(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ProductService productService = new ProductServiceImpl();
List<Product> products = productService.findAll();
req.setAttribute("products", products);
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("/shoppingstore.jsp");
rd.forward(req, res);
}
/*
* 查看购物车
*
*/
private void lookCart(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
Set<Product> shoppingcart = UserServiceImpl.getShoppingcart();
req.setAttribute("shoppingcart", shoppingcart);
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("/shoppingcart.jsp");
rd.forward(req, res);
}
/*
* 退出
*/
private void quit(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
UserService us = new UserServiceImpl();
us.quit(req, res);
}
/*
* 查找书籍
*/
private void findBook(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ProductService productService = new ProductServiceImpl();
List<Product> products = productService.findByModel("book");
req.setAttribute("products", products);
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("/shoppingstore.jsp");
rd.forward(req, res);
}
/*
* 查找家电
*/
private void findHomeDevice(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ProductService productService = new ProductServiceImpl();
List<Product> products = productService.findByModel("homeDevice");
req.setAttribute("products", products);
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("/shoppingstore.jsp");
rd.forward(req, res);
}
/*
* 查找手机
*/
private void findMobilePhone(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ProductService productService = new ProductServiceImpl();
List<Product> products = productService.findByModel("mobilePhone");
req.setAttribute("products", products);
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("/shoppingstore.jsp");
rd.forward(req, res);
}
/*
* 查找电脑
*/
private void findComputer(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ProductService productService = new ProductServiceImpl();
List<Product> products = productService.findByModel("computer");
req.setAttribute("products", products);
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("/shoppingstore.jsp");
rd.forward(req, res);
}
/*
* 搜索
*/
private void search(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ProductService productService = new ProductServiceImpl();
List<Product> products = productService.findByName(req, res);
req.setAttribute("products", products);
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("/shoppingstore.jsp");
rd.forward(req, res);
}
/*
* 查找所有的商品
*/
private void findAllProducts(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ProductService pro
没有合适的资源?快使用搜索试试~ 我知道了~
购物车或在线购物系统
共63个文件
class:21个
java:21个
jsp:10个
需积分: 0 20 下载量 71 浏览量
2008-09-22
18:48:56
上传
评论
收藏 62KB RAR 举报
温馨提示
这是一个在线购物系统,是用Servlet,jsp,MySQL数据库编写的.
资源详情
资源评论
资源推荐
收起资源包目录
shoppingonline.rar (63个子文件)
shoppingonline
.project 1KB
.mymetadata 315B
WebRoot
shoppingstore.jsp 3KB
WEB-INF
web.xml 567B
lib
classes
com
wsr
shoppingonline
biz
UserService.class 473B
OrderItemsService.class 292B
OrderService.class 530B
impl
ProductServiceImpl.class 6KB
OrderItemsServiceImpl.class 4KB
OrderServiceImpl.class 5KB
UserServiceImpl.class 8KB
ProductService.class 727B
dao
DBOption.class 1013B
DBConnection.class 280B
impl
DBConnectionByJDBC.class 3KB
TestDBCon.class 1KB
DBConnectionByHbn.class 748B
DBOptionImpl.class 6KB
action
ActionServlet.class 13KB
errorandexception
util
ConnectionFactory.class 502B
ReleaseResource.class 908B
pojo
Order.class 2KB
User.class 3KB
OrderItems.class 1KB
Product.class 2KB
DBConfig.properties 95B
index.jsp 3KB
META-INF
context.xml 315B
MANIFEST.MF 39B
orderdetail.jsp 1KB
order.jsp 3KB
modify.jsp 6KB
shoppingcart.jsp 3KB
usermanager.jsp 1KB
register.html 5KB
userorder.jsp 2KB
login.html 790B
productinfo.jsp 2KB
userinfo.jsp 1KB
数据库中的表 3KB
.myeclipse
src
com
wsr
shoppingonline
biz
UserService.java 1KB
OrderItemsService.java 262B
impl
ProductServiceImpl.java 5KB
OrderItemsServiceImpl.java 2KB
OrderServiceImpl.java 3KB
UserServiceImpl.java 9KB
ProductService.java 1KB
OrderService.java 883B
dao
DBOption.java 1KB
impl
DBConnectionByJDBC.java 2KB
DBOptionImpl.java 6KB
TestDBCon.java 458B
DBConnectionByHbn.java 594B
DBConnection.java 279B
action
ActionServlet.java 17KB
errorandexception
util
ReleaseResource.java 630B
ConnectionFactory.java 254B
pojo
Order.java 2KB
User.java 2KB
OrderItems.java 1KB
Product.java 2KB
DBConfig.properties 95B
.classpath 454B
共 63 条
- 1
wsr88
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0