コード例 #1
0
  public void doFilter(
      ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
      throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;
    HttpServletResponse response = (HttpServletResponse) servletResponse;
    String uri = request.getParameter("uri");
    response.setContentType("text/html");
    response.setCharacterEncoding("UTF-8");
    String rLastEdit = request.getParameter("lastEdit");
    if (rLastEdit == null) return;
    long userLastEdit = Long.parseLong(rLastEdit);
    if (clipStatus.hasAccess(request.getSession().getId(), uri)) {
      Connection con = dbCon.getConnection();
      try {
        Clip clip = ClipAgent.getInstance().loadClip(uri, con);
        if (clip != null) {
          DateFormat df = DateFormat.getDateTimeInstance();
          String textAreaValue = clip.getValue();
          Pattern p = Pattern.compile("</\\s*textarea", Pattern.CASE_INSENSITIVE);
          Matcher m = p.matcher(textAreaValue);

          textAreaValue = m.replaceAll("textarea");
          response.getOutputStream().write(textAreaValue.getBytes("UTF-8"));
        }
      } finally {
        dbCon.returnConnection(con);
      }
    } else {

      response.getOutputStream().print("");
    }
    response.getOutputStream().flush();
  }
コード例 #2
0
 public void init(FilterConfig filterConfig) throws ServletException {
   clipStatus = ClipStatus.getInstance();
 }