a filter that turns the entire page into lower case

Posted on 2005-04-17
Last Modified: 2010-04-01

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 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);
      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() {
  public void destroy() {}

and this is from web.xml file.



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

Question by:dkim18
    1 Comment
    LVL 29

    Accepted Solution

    write it out via the response.getOutputStream()/response.getWriter()

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
    For Sennheiser, comfort, quality and security are high priority areas. This paper addresses the security of Bluetooth technology and the supplementary security that Sennheiser’s Contact Center and Office (CC&O) headsets provide.  
    This video discusses moving either the default database or any database to a new volume.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now