FileDocCategorySizeDatePackage
DateFilter.javaAPI DocExample1341Wed Apr 05 11:25:42 BST 2000None

DateFilter

public class DateFilter extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)

  
    PrintWriter out = resp.getWriter();

    String contentType = req.getContentType();
    if (contentType == null) 
      return; // No incoming data
    
    // Note that if we were using MIME filtering we would have to set this to 
    // something different to avoid an infinite loop
    resp.setContentType(contentType); 

    BufferedReader br = new BufferedReader(req.getReader());

    String line = null;
    Date d = new Date();
    while ((line = br.readLine()) != null) {
      int index;
      while ((index=line.indexOf("<DATE>")) >= 0) 
        line = line.substring(0, index) + d + line.substring(index + 6);
      out.println(line); 
    }
    br.close();