Demos and Usage of javax.servlet.ServletRequest.setCharacterEncoding(String encoding)


   1: import javax.servlet.ServletException;
   2: import javax.servlet.ServletRequest;
   3: import javax.servlet.ServletResponse;
   4:         ...
   5: 
   6:     public void doFilter(ServletRequest arg0, ServletResponse arg1,
   7:             FilterChain arg2) throws IOException, ServletException {
   8:         ...
   9:         System.out.println("���������ַ�");
  10:         arg0.setCharacterEncoding(newCharSet);
  11:         

View Full Code Here
   1: import javax.servlet.ServletException;
   2: import javax.servlet.ServletRequest;
   3: import javax.servlet.ServletResponse;
   4:         ...
   5: 
   6:   public void doFilter(ServletRequest request,
   7:                        ServletResponse response,
   8:         ...
   9: 
  10:     request.setCharacterEncoding(encoding);
  11:     chain.doFilter(request, response);

View Full Code Here
   1: 
   2:     public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
   3:         ...
   4:         if (servletRequest.getCharacterEncoding() == null && this.encoding != null) {
   5:         ...
   6:             servletRequest.setCharacterEncoding(this.encoding);
   7:         }

View Full Code Here
   1: import javax.servlet.ServletException;
   2: import javax.servlet.ServletRequest;
   3: import javax.servlet.ServletResponse;
   4:         ...
   5: 
   6:       public void doFilter( ServletRequest request,
   7:                             ServletResponse response,
   8:         ...
   9: 
  10:          request.setCharacterEncoding( REQUEST_ENCODING );
  11:          

View Full Code Here
   1: import javax.servlet.ServletException;
   2: import javax.servlet.ServletRequest;
   3: import javax.servlet.ServletResponse;
   4:         ...
   5: 
   6:     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
   7:     throws IOException, ServletException {
   8:         ...
   9:         if (encoding == null)
  10:             request.setCharacterEncoding("UTF-8");
  11:         chain.doFilter(request, response);

View Full Code Here
   1: import javax.servlet.ServletException;
   2: import javax.servlet.ServletRequest;
   3: import javax.servlet.ServletResponse;
   4:         ...
   5:     public void doFilter(
   6:             ServletRequest request, 
   7:             ServletResponse response, 
   8:         ...
   9:             FilterChain chain) throws IOException, ServletException {
  10:         request.setCharacterEncoding(encoding);
  11:         ...
  12:         response.setCharacterEncoding(encoding);

View Full Code Here
   1:     public void doFilter(
   2:             ServletRequest req, ServletResponse res, FilterChain chain)
   3:                 throws IOException, ServletException {
   4:         ...
   5:                 if(encoding != null) {
   6:                     req.setCharacterEncoding(encoding);
   7:                 }
   8:         ...
   9: 
  10:     protected String getEncoding(ServletRequest req) {
  11:         return this.encoding;

View Full Code Here
   1: import javax.servlet.ServletException;
   2: import javax.servlet.ServletRequest;
   3: import javax.servlet.ServletResponse;
   4:         ...
   5: 
   6:     public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException,
   7:         ServletException {
   8:         ...
   9: 
  10:     private void setContentType(ServletRequest req, ServletResponse resp) {
  11:         resp.setContentType(MIMEMapping.getMIMEType((HttpServletRequest) req));
  12:         ...
  13:         try {
  14:             req.setCharacterEncoding(characterEncoding);

View Full Code Here
   1:     
   2:     public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain)
   3:         throws IOException, ServletException
   4:         ...
   5:                 if (enc == null)
   6:                     request.setCharacterEncoding(WebEnv.ENCODING);
   7:                 if (enc == null)
   8:                     log.finer("Checked=" + uri);
   9:                 else

View Full Code Here
   1: import javax.servlet.ServletException;
   2: import javax.servlet.ServletRequest;
   3: import javax.servlet.ServletResponse;
   4:         ...
   5: 
   6:     public void doFilter(ServletRequest request, ServletResponse response,
   7:                          FilterChain chain)
   8:         ...
   9:         if (encoding != null)
  10:             request.setCharacterEncoding(encoding);

View Full Code Here
   1: import javax.servlet.ServletException;
   2: import javax.servlet.ServletRequest;
   3: import javax.servlet.ServletResponse;
   4:         ...
   5:   @Override
   6:   public void doFilter(ServletRequest request, ServletResponse response)
   7:     throws ServletException, IOException
   8:         ...
   9:     if (_requestCharacterEncoding != null)
  10:       request.setCharacterEncoding(_requestCharacterEncoding);
  11: 
  12:         ...
  13: 
  14:       request.setCharacterEncoding(_requestCharacterEncoding);

View Full Code Here
   1: 
   2: package tests.javax_servlet.ServletRequest;
   3: 
   4:         ...
   5: import javax.servlet.ServletRequest;
   6: import javax.servlet.ServletResponse;
   7:         ...
   8: 
   9:     public void service ( ServletRequest request, ServletResponse response ) throws ServletException, IOException {
  10: 
  11:         ...
  12:         try {
  13:             request.setCharacterEncoding( "doesnotexist" );

View Full Code Here
   1: 
   2:     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
   3:         throws IOException, ServletException
   4:         ...
   5:                 if (enc == null)
   6:                     request.setCharacterEncoding(WebEnv.ENCODING);
   7:             }
   8:             catch (Exception e)
   9:             {

View Full Code Here
   1: import javax.servlet.ServletException;
   2: import javax.servlet.ServletRequest;
   3: import javax.servlet.ServletResponse;
   4:         ...
   5: 
   6:     public void doFilter(ServletRequest request, ServletResponse response,
   7:                          FilterChain chain)
   8:         ...
   9:             if (encoding != null)
  10:                 request.setCharacterEncoding(encoding);
  11:         }
  12:         ...
  13: 
  14:     protected String selectEncoding(ServletRequest request) {

View Full Code Here
   1: import javax.servlet.ServletException;
   2: import javax.servlet.ServletRequest;
   3: import javax.servlet.ServletResponse;
   4:         ...
   5: 
   6:     public void doFilter(ServletRequest request, ServletResponse response,
   7:                          FilterChain chain)
   8:         ...
   9:             if (encoding != null)
  10:                 request.setCharacterEncoding(encoding);
  11:         }
  12:         ...
  13: 
  14:     protected String selectEncoding(ServletRequest request) {

View Full Code Here