• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

regular expression and using replaceAll() - works locally, but not in school server

Hi!

I put this question yesterday(http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21392112.html) and got solution, but it doesn’t work when I test it in school server. So, this only works locally. Does anyone know why?

++++++++++++++
package moreservlets.filters;

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


public class RemoveBlinkTagFilter 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);
     
         String str = responseWrapper.toString();

            //str.replaceAll("(<blink>|</blink>)", "");
                  str = str.replaceAll("</?[bB][lL][iI][nN][kK]>", "");       
                  
            PrintWriter out = res.getWriter();
            out.write(str);
          
    }
 

  /** 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() {}

}
0
dkim18
Asked:
dkim18
  • 4
  • 4
1 Solution
 
koppchaCommented:
Do you get any error?
0
 
dkim18Author Commented:
you know what? I tried yours in my work place and it worked in school server and locally.
I don't why it didn't work yesterday and I still don't know why object's code works locally, but doesn't work in school server.
I will give you point anyway because you provided me solution....

thanks anyway..
0
 
dkim18Author Commented:
String raj=name.replaceAll("(<BLINK>|</BLINK>)","");
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
dkim18Author Commented:
actually, this doesn't work the following tags.

<H1><blink> BLINK </blink></H1><BR>

<H1><BlInK> BLINK </BlInK></H1>

0
 
koppchaCommented:
ok try the other one i have given yesterday for this
0
 
koppchaCommented:
str.replaceAll("(<[bB][lL][iI][nN][kK]>|</[bB][lL][iI][nN][kK]>)","");
0
 
koppchaCommented:
Let me know
0
 
dkim18Author Commented:
right...that works too...
thanks!
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.

Join & Write a Comment

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.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now