Practice filtering sensitive words for user input

Source: Internet
Author: User

<%@ Page Language="Java"ContentType="text/html; Charset=utf-8"pageencoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd "><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Insert Title here</title></Head><Body><formAction= "newfile3.jsp"Method= "POST"><inputtype= "text"name= "Name"><inputtype= "Submit"value= "Submit"></form></Body></HTML>
<%@ Page Language="Java"ContentType="text/html; Charset=utf-8"pageencoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd "><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Insert Title here</title></Head><Body><%StringN=Request.getattribute ("name1"). toString ();%><inputtype= "text"value= "<%=n%>"></Body></HTML>
 PackageCom.hanqi.web;Importjava.io.IOException;ImportJavax.servlet.Filter;ImportJavax.servlet.FilterChain;ImportJavax.servlet.FilterConfig;Importjavax.servlet.ServletException;Importjavax.servlet.ServletRequest;ImportJavax.servlet.ServletResponse; Public classTestFilter1ImplementsFilter { PublicTestFilter1 () {} Public voiddestroy () {} Public voidDoFilter (ServletRequest request, servletresponse response, Filterchain chain)throwsIOException, servletexception {String str=request.getparameter ("name"); String str1=str.replaceall ("The", "*"); Request.setattribute ("Name1", STR1);        System.out.println (STR1);    Chain.dofilter (request, response); }         Public voidInit (Filterconfig fconfig)throwsservletexception {}}
  <filter>    <display-name>TestFilter1</display-name>    <filter-name>TestFilter1< /filter-name>    <filter-class>com.hanqi.web.testfilter1</filter-class>  </filter>  <filter-mapping>    <filter-name>TestFilter1</filter-name>    < Url-pattern>/newfile3.jsp</url-pattern>  </filter-mapping>

Practice filtering sensitive words for user input

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.