package com.myfilter;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MyFilter extends HttpServlet implements Filter {
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
// TODO Auto-generated method stub
arg0.setCharacterEncoding("UTF-8");
arg1.setCharacterEncoding("UTF-8");
arg2.doFilter(arg0, arg1);
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
/**
* Constructor of the object.
*/
public MyFilter() {
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");
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 GET method");
out.println(" </BODY>");
out.println("</HTML>");
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 {
this.doGet(request, response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
home.rar (50个子文件)
home
.project 1KB
.mymetadata 285B
WebRoot
WEB-INF
struts-tiles.tld 8KB
dwr.xml 554B
.struts-config.mex 48B
web.xml 2KB
struts-config.xml 418B
struts-bean.tld 9KB
struts-nested.tld 63KB
struts-html.tld 65KB
struts-template.tld 2KB
struts-logic.tld 14KB
validator-rules.xml 41KB
lib
commons-logging.jar 31KB
commons-digester.jar 107KB
commons-fileupload.jar 22KB
commons-beanutils.jar 116KB
commons-lang.jar 62KB
msbase.jar 278KB
struts.jar 486KB
commons-validator.jar 46KB
mssqlserver.jar 63KB
struts-legacy.jar 10KB
dwr.jar 478KB
msutil.jar 58KB
jakarta-oro.jar 64KB
commons-collections.jar 161KB
classes
com
dao
Homeshen.class 2KB
Homeshi.class 2KB
db
Dbmanage.class 1KB
struts
ApplicationResources.properties 75B
myfilter
MyFilter.class 2KB
command
Comshi.class 901B
Comshen.class 719B
po
Homeshen.class 907B
Homeshi.class 1KB
META-INF
MANIFEST.MF 39B
home.jsp 3KB
无标题1.sql 712B
.myeclipse
src
com
dao
Homeshen.java 999B
Homeshi.java 1KB
db
Dbmanage.java 566B
struts
ApplicationResources.properties 75B
myfilter
MyFilter.java 3KB
command
Comshen.java 318B
Comshi.java 454B
po
Homeshen.java 317B
Homeshi.java 360B
.mystrutsdata 250B
.classpath 1KB
共 50 条
- 1
jyq0105
- 粉丝: 8
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1