[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

a filter that turns the entire page into lower case

Posted on 2005-04-17
1
Medium Priority
?
467 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:dkim18
1 Comment
 
LVL 29

Accepted Solution

by:
bloodredsun earned 400 total points
ID: 13802631
write it out via the response.getOutputStream()/response.getWriter()
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Exchange administrators are always vigilant about Exchange crashes and disasters that are possible any time. It is quite essential to identify the symptoms of a possible Exchange issue and be prepared with a proper recovery plan. There are multiple…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

872 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