Package util

Examples of util.Counter


        }

        StringWriter sw = new StringWriter();
        PrintWriter writer = new PrintWriter(sw);

        Counter counter = (Counter) filterConfig.getServletContext()
                                                .getAttribute("hitCounter");
        writer.println();
        writer.println(
                "=======================================================");
        writer.println("The number of hits is: " + counter.incCounter());
        writer.println(
                "=======================================================");

        // Log the resulting string
        writer.flush();
        System.out.println(sw.getBuffer().toString());

        PrintWriter out = response.getWriter();
        CharResponseWrapper wrapper = new CharResponseWrapper(
                    (HttpServletResponse) response);
        chain.doFilter(request, wrapper);

        CharArrayWriter caw = new CharArrayWriter();
        caw.write(
                wrapper.toString().substring(
                        0,
                        wrapper.toString().indexOf("</body>") - 1));
        caw.write(
                "<p>\n<center>" + messages.getString("Visitor")
                + "<font color='red'>" + counter.getCounter()
                + "</font></center>");
        caw.write("\n</body></html>");
        response.setContentLength(caw.toString()
                                     .getBytes().length);
        out.write(caw.toString());
View Full Code Here


    private ServletContext context = null;

    public void contextInitialized(ServletContextEvent event) {
        context = event.getServletContext();

        Counter counter = new Counter();
        context.setAttribute("hitCounter", counter);
        counter = new Counter();
        context.setAttribute("orderCounter", counter);

        try {
            BookDBAO bookDB = new BookDBAO(emf);
            context.setAttribute("bookDB", bookDB);
View Full Code Here

        }
       
        wsdlDefinition = def;
        wsdlURL = wURL;

        accessCount = new Counter();

        releaseResources();
    }
View Full Code Here

        }
       
        wsdlDefinition = def;
        wsdlURL = wURL;

        accessCount = new Counter();

        releaseResources();
    }
View Full Code Here

            return;

         StringWriter sw = new StringWriter();
         PrintWriter writer = new PrintWriter(sw);
        
         Counter counter = (Counter)filterConfig.getServletContext().getAttribute("hitCounter");
         writer.println();
         writer.println("=======================================================");
         writer.println("The number of hits is: " + counter.incCounter());
         writer.println("=======================================================");

         // Log the resulting string
         writer.flush();
         filterConfig.getServletContext().log(sw.getBuffer().toString());
        
         PrintWriter out = response.getWriter();
         CharResponseWrapper wrapper = new CharResponseWrapper((HttpServletResponse)response);
         chain.doFilter(request, wrapper);
         int index = wrapper.getData().indexOf("</body></html>");
         out.write(wrapper.getData().substring(0, index-1));
         out.println("<center>You are visitor number <font color=\"red\">" + counter.getCounter() + "</font></center>");
         out.println("</body></html>");
    }
View Full Code Here

            context.setAttribute("bookDB", bookDB);
         } catch (Exception ex) {
            context.log("Couldn't create bookstore database bean: " + ex.getMessage());
         }

         Counter counter = new Counter();
         context.setAttribute("hitCounter", counter);
         counter = new Counter();
         context.setAttribute("orderCounter", counter);
    }
View Full Code Here

            context.setAttribute("bookDB", bookDB);
         } catch (Exception ex) {
            System.out.println("Couldn't create bookstore database bean: " + ex.getMessage());
         }

         Counter counter = new Counter();
         context.setAttribute("hitCounter", counter);
         counter = new Counter();
         context.setAttribute("orderCounter", counter);
    }
View Full Code Here

         session.setAttribute("messages", messages);
      }
      StringWriter sw = new StringWriter();
      PrintWriter writer = new PrintWriter(sw);

      Counter counter = (Counter)filterConfig.getServletContext().getAttribute("hitCounter");
      writer.println();
      writer.println("=======================================================");
      writer.println("The number of hits is: " + counter.incCounter());
      writer.println("=======================================================");

      // Log the resulting string
      writer.flush();
      System.out.println(sw.getBuffer().toString());

      PrintWriter out = response.getWriter();
      CharResponseWrapper wrapper = new CharResponseWrapper((HttpServletResponse)response);
      chain.doFilter(request, wrapper);
      CharArrayWriter caw = new CharArrayWriter();
      caw.write(wrapper.toString().substring(0, wrapper.toString().indexOf("</body>")-1));
      caw.write("<p>\n<center>" + messages.getString("Visitor") + "<font color='red'>" + counter.getCounter() + "</font></center>");
      caw.write("\n</body></html>");
      response.setContentLength(caw.toString().getBytes().length);
      out.write(caw.toString());       
      out.close();
    }
View Full Code Here

TOP

Related Classes of util.Counter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.