?
Solved

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

Posted on 2005-04-18
8
Medium Priority
?
259 Views
Last Modified: 2012-05-05
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
Comment
Question by:dkim18
  • 4
  • 4
8 Comments
 
LVL 8

Accepted Solution

by:
koppcha earned 400 total points
ID: 13809346
Do you get any error?
0
 

Author Comment

by:dkim18
ID: 13809381
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
 

Author Comment

by:dkim18
ID: 13809385
String raj=name.replaceAll("(<BLINK>|</BLINK>)","");
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:dkim18
ID: 13809419
actually, this doesn't work the following tags.

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

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

0
 
LVL 8

Expert Comment

by:koppcha
ID: 13809427
ok try the other one i have given yesterday for this
0
 
LVL 8

Expert Comment

by:koppcha
ID: 13809436
str.replaceAll("(<[bB][lL][iI][nN][kK]>|</[bB][lL][iI][nN][kK]>)","");
0
 
LVL 8

Expert Comment

by:koppcha
ID: 13809437
Let me know
0
 

Author Comment

by:dkim18
ID: 13809687
right...that works too...
thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
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…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

850 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