• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Fudging Filter Functionality as a method call

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way that I can fudge filter functionality as a method call.
I am having problem using Jason Falkner's Compression Filter using Struts. Apparently, our application (developed by previous developers) is doing ServletChaining and I am getting exception.
I want to use Jason Falkner's CompressionFilter.
But can I use it as a method call, instead of using it as a Filter? I have no other filter in the application.

Jason Falkner's Compression Filter:

public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
if (req instanceof HttpServletRequest) {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
String ae = request.getHeader("accept-encoding");
// String doCompression = req.getParameter("doCompession");
if (ae != null && ae.indexOf("gzip") != -1) {
System.out.println("GZIP supported, compressing.");
GZIPResponseWrapper wrappedResponse =
new GZIPResponseWrapper(response);
chain.doFilter(req, wrappedResponse);
wrappedResponse.finishResponse();
return;
}
chain.doFilter(req, res);

}
}

I tried using it as a method call by commenting out line chain.doFilter(req, wrappedResponse). As I saidd, there is no filter in the application. Chain.doFilter(..) in reality passes control to the resource that has to be compressed. After that, control comes back to wrappedResponse.finishResponse() line.

However, if I try to use doFilter as a method call by commenting out chain.doFilter(req, wrappedResponse), and call it at some place of a Servlet, it does not do any good. Key is, control has to come back to filter for it to be compressed.

Any thoughts?
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic