/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
/**
*
* @author pcw
*/
public class CodeFilter implements Filter {
private static final boolean debug = true;
// The filter configuration object we are associated with. If
// this value is null, this filter instance is not currently
// configured.
private FilterConfig filterConfig = null;
public CodeFilter() {
}
private void doBeforeProcessing(ServletRequest request, ServletResponse response)
throws IOException, ServletException {
if (debug) {
log("ServletFilter:DoBeforeProcessing");
}
}
private void doAfterProcessing(ServletRequest request, ServletResponse response)
throws IOException, ServletException {
if (debug) {
log("ServletFilter:DoAfterProcessing");
}
}
/**
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
* @param chain The filter chain we are processing
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
System.out.println("start-doFilter");
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
//设置过滤页数据的面显示数据的编码
if (debug) {
log("ServletFilter:doFilter()");
}
doBeforeProcessing(request, response);
Throwable problem = null;
try {
chain.doFilter(request, response);
} catch (Throwable t) {
// If an exception is thrown somewhere down the filter chain,
// we still want to execute our after processing, and then
// rethrow the problem after that.
problem = t;
t.printStackTrace();
}
doAfterProcessing(request, response);
// If there was a problem, we want to rethrow it if it is
// a known type, otherwise log it.
if (problem != null) {
if (problem instanceof ServletException) {
throw (ServletException) problem;
}
if (problem instanceof IOException) {
throw (IOException) problem;
}
sendProcessingError(problem, response);
}
}
/**
* Return the filter configuration object for this filter.
*/
public FilterConfig getFilterConfig() {
return (this.filterConfig);
}
/**
* Set the filter configuration object for this filter.
*
* @param filterConfig The filter configuration object
*/
public void setFilterConfig(FilterConfig filterConfig) {
this.filterConfig = filterConfig;
}
/**
* Destroy method for this filter
*/
public void destroy() {
}
/**
* Init method for this filter
*/
public void init(FilterConfig filterConfig) {
this.filterConfig = filterConfig;
if (filterConfig != null) {
if (debug) {
log("ServletFilter:Initializing filter");
}
}
}
/**
* Return a String representation of this object.
*/
@Override
public String toString() {
if (filterConfig == null) {
return ("ServletFilter()");
}
StringBuffer sb = new StringBuffer("ServletFilter(");
sb.append(filterConfig);
sb.append(")");
return (sb.toString());
}
private void sendProcessingError(Throwable t, ServletResponse response) {
String stackTrace = getStackTrace(t);
if (stackTrace != null && !stackTrace.equals("")) {
try {
response.setContentType("text/html");
PrintStream ps = new PrintStream(response.getOutputStream());
PrintWriter pw = new PrintWriter(ps);
pw.print("<html>\n<head>\n<title>Error</title>\n</head>\n<body>\n"); //NOI18N
// PENDING! Localize this for next official release
pw.print("<h1>The resource did not process correctly</h1>\n<pre>\n");
pw.print(stackTrace);
pw.print("</pre></body>\n</html>"); //NOI18N
pw.close();
ps.close();
response.getOutputStream().close();
} catch (Exception ex) {
}
} else {
try {
PrintStream ps = new PrintStream(response.getOutputStream());
t.printStackTrace(ps);
ps.close();
response.getOutputStream().close();
} catch (Exception ex) {
}
}
}
public static String getStackTrace(Throwable t) {
String stackTrace = null;
try {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
pw.close();
sw.close();
stackTrace = sw.getBuffer().toString();
} catch (Exception ex) {
}
return stackTrace;
}
public void log(String msg) {
filterConfig.getServletContext().log(msg);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于javaEE网上商城管理系统采用了Java语言,基于B/S结构,idea作为本系统的开发工具,数据库采用的是开源MySQL来设计。前台包括登录注册、首页、我的订单、等功能模块。可以方便管理以及进行更加方便快捷的管理,可以提高基于javaEE网上商城管理系统信息管理效率。 本网站游泳到MySQL为数据库开发平台,采用Java开发技术实现前台用户页面和后台管理员管理页面。此系统的开发改善了一些技术和增加创新,使之代替了传统的销售方式,解决了管理困难、销售成本高等问题。同时此系统具有使用简单,用户界面友好,便于操作等特点。 内含项目完整代码,数据库及配套报告。
资源推荐
资源详情
资源评论
收起资源包目录
JAVAEE-商城管理系统 (155个子文件)
LoginFilter.class 5KB
CodeFilter.class 5KB
CodeFilter.class 5KB
newjsp_jsp.class 4KB
LoginFilter.class 3KB
DBean.class 2KB
DBean.class 2KB
JDBCdemo.class 2KB
GoodsBean.class 2KB
GoodsBean.class 2KB
.classpath 766B
org.eclipse.wst.common.component 480B
org.eclipse.wst.jsdt.ui.superType.container 49B
Shopping.css 1KB
Shopping.css 1KB
Shopping.css 1KB
Login.css 958B
Login.css 958B
Login.css 958B
Register.css 943B
Register.css 943B
Register.css 943B
ShoppingCart.css 704B
ShoppingCart.css 704B
ShoppingCart.css 690B
gfv3ee6.dpf 476B
sqljdbc42.jar 878KB
CodeFilter.java 6KB
CodeFilter.java 6KB
LoginFilter.java 5KB
LoginFilter.java 4KB
newjsp_jsp.java 3KB
DBean.java 2KB
DBean.java 2KB
JDBCdemo.java 2KB
GoodsBean.java 978B
GoodsBean.java 978B
top.jpg 389KB
top.jpg 389KB
top.jpg 389KB
register_background.jpg 234KB
register_background.jpg 234KB
register_background.jpg 234KB
flowerCake.jpg 162KB
flowerCake.jpg 162KB
flowerCake.jpg 162KB
multiCake.jpg 151KB
multiCake.jpg 151KB
multiCake.jpg 151KB
login_background.jpg 110KB
login_background.jpg 110KB
login_background.jpg 110KB
chrisCake.jpg 81KB
chrisCake.jpg 81KB
chrisCake.jpg 81KB
blackRose.jpg 71KB
blackRose.jpg 71KB
blackRose.jpg 71KB
cherryCake.jpg 65KB
cherryCake.jpg 65KB
cherryCake.jpg 65KB
log.jpg 64KB
log.jpg 64KB
log.jpg 64KB
triangleCake.jpg 53KB
triangleCake.jpg 53KB
triangleCake.jpg 53KB
purpleRose.jpg 47KB
purpleRose.jpg 47KB
purpleRose.jpg 47KB
redRose.jpg 47KB
redRose.jpg 47KB
redRose.jpg 47KB
yellowRose.jpg 42KB
yellowRose.jpg 42KB
yellowRose.jpg 42KB
birthCake.jpg 41KB
birthCake.jpg 41KB
birthCake.jpg 41KB
snackCake.jpg 39KB
snackCake.jpg 39KB
snackCake.jpg 39KB
pinkRose.jpg 38KB
pinkRose.jpg 38KB
pinkRose.jpg 38KB
blueRose.jpg 37KB
blueRose.jpg 37KB
blueRose.jpg 37KB
greenRose.jpg 36KB
greenRose.jpg 36KB
greenRose.jpg 36KB
whiteRose.jpg 33KB
whiteRose.jpg 33KB
whiteRose.jpg 33KB
dogCake.jpg 29KB
dogCake.jpg 29KB
dogCake.jpg 29KB
ShoppingCart_background.jpg 20KB
ShoppingCart_background.jpg 20KB
ShoppingCart_background.jpg 20KB
共 155 条
- 1
- 2
资源评论
- Long_qyy2023-09-30这个商城项目做的真的很好,功能也十分完善,期待博主的下一次分享!!
edgarrrr
- 粉丝: 1229
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功