a filter that turns the entire page into lower case

Hello!

I am making a filter that turns the entire page(HTML tags and all) into lower case(I don’t have to worry about legal HTML) and this is what I did so far.( It does display lower case page to tomcat windows.) Now, how do I output this to browser?

package moreservlets.filters;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.lang.*;


public class LowerCaseFilter implements Filter {
  private FilterConfig config;
 
  public void doFilter(ServletRequest request,
                       ServletResponse response,
                       FilterChain chain)
      throws ServletException, IOException {
    HttpServletRequest req = (HttpServletRequest)request;
    HttpServletResponse res = (HttpServletResponse)response;
   
     
      // Invoke resource, accumulating output in the wrapper.
      CharArrayWrapper responseWrapper =
        new CharArrayWrapper(res);
      chain.doFilter(req,responseWrapper);
     
     
      char[] responseChars = responseWrapper.toCharArray();
      
      String responseChars = responseWrapper.toString().toLowerCase();
            
      System.out.println(responseChars );
     
   
    }
 

  /** Store the FilterConfig object in case subclasses
   *  want it.
   */
 
  public void init(FilterConfig config)
      throws ServletException {
    this.config = config;
  }

  protected FilterConfig getFilterConfig() {
    return(config);
  }
 
  public void destroy() {}

}
+++++++
and this is from web.xml file.

  <filter>
    <filter-name>LowerCaseFilter</filter-name>
    <filter-class>moreservlets.filters.LowerCaseFilter</filter-class>
  </filter>


 <filter-mapping>
    <filter-name>LowerCaseFilter</filter-name>
    <url-pattern>/plugSite/UpperCasePage.jsp</url-pattern>
 </filter-mapping>

after I requested the page, I got the following as output.

[c@1722456
dkim18Asked:
Who is Participating?
 
bloodredsunConnect With a Mentor Commented:
write it out via the response.getOutputStream()/response.getWriter()
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.