内容发布更新时间 : 2024/11/15 0:04:15星期一 下面是文章的全部内容请认真阅读。
}
}
String name = request.getParameter(\String word = request.getParameter(\
word = word.replace(\日你\word = word.replace(\狗日的\word = word.replace(\你妹\word = word.replace(\操你\word = word.replace(\你妈的\
req.setAttribute(\chain.doFilter(request, response);
@Override
public void init(FilterConfig FilterConfig) throws ServletException { // TODO Auto-generated method stub this.config = FilterConfig; }
Encoding.java
package com;
import java.io.IOException; 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.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
public class Encoding implements Filter { protected String encoding = null; protected FilterConfig config; @Override public void destroy() { // TODO Auto-generated method stub
}
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest)request; HttpServletResponse resp = (HttpServletResponse)response; request.setCharacterEncoding(\ response.setCharacterEncoding(\ chain.doFilter(request, response); }
@Override
public void init(FilterConfig FilterConfig) throws ServletException { this.config = FilterConfig; this.encoding = FilterConfig.getInitParameter(\}
protected String getEncoding(){ return encoding; }
CheckForm.jsp
<%@ page language=\ contentType=\ pageEncoding=\%>
过滤校验:
CheckFormOver.jsp
<%@ page language=\ contentType=\ pageEncoding=\%>
您提交的数据:
校验结果!
web.xml
xmlns:web=\ xsi:schemaLocation=\ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd\ id=\ version=\>
3. LogoutServlet.java OnlineUserServlet.java User.java UserList.java Login.html web.xml
LogoutServlet.java
package com;
import java.io.IOException; import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession;
import org.apache.catalina.connector.Response;
public class LogoutServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet{
public LogoutServlet() { super(); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
response.setContentType(\ HttpSession session = request.getSession(); User user = (User)session.getAttribute(\ session.invalidate(); PrintWriter out = response.getWriter(); out.println(\退出登录
\ out.println(user.getName()+\你已退出登录\ out.println(\重新登录\ out.println(\ out.close(); } }
OnlineUserServlet.java
package com;
import java.io.*;
import java.util.Enumeration; import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;