tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Álvaro Morillas (Sortes Ing. Inf. S.L.) <amoril...@sortes.com>
Subject RE: Requests being processed at a certain moment
Date Wed, 04 Jun 2008 11:51:42 GMT
Thank you, Jim and David. I've been trying setting a Filter and it works ok.
Now I must figure out how to research the logs to find requests not served,
but I'm afraid it's a topic out of this mailing list.


 
Álvaro Morillas Correa
VicioJuegos.com - Sortes Ing. Inf., S.L.
 
Plaza Mayor, 25, 1º, Of. 9-B
28911 Leganés (Madrid)
Teléfono: 916943388 – Móvil: 617315926
Horario: L-J: 9:00-14:00, 15:00-18:30 | V: 9:00-15:00


-----Mensaje original-----
De: David Fisher [mailto:dfisher@jmlafferty.com] 
Enviado el: martes, 03 de junio de 2008 17:39
Para: Tomcat Users List
Asunto: Re: Requests being processed at a certain moment

Alvaro,

You certainly can easily use a Filter with your JSPs.

Take a look at the jsp-examples webapps included with tomcat. If you  
look at WEB-INF/web.xml and the structure of WEB-INF/classes/ you  
should see how to use the example that Jim provided.

For example RequestDumper:

In web.xml

     <filter-mapping>
         <filter-name>Request Dumper Filter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>

In classes/filters/RequestDumper.java:

     public void doFilter(ServletRequest request, ServletResponse  
response,
                          FilterChain chain)
         throws IOException, ServletException {

         if (filterConfig == null)
             return;

         // Render the generic servlet request properties
         StringWriter sw = new StringWriter();
         PrintWriter writer = new PrintWriter(sw);
         writer.println("Request Received at " +
                        (new Timestamp(System.currentTimeMillis())));
	....
         // Log the resulting string
         writer.flush();
          
filterConfig.getServletContext().log(sw.getBuffer().toString());

         // Pass control on to the next filter
         chain.doFilter(request, response);

     }

I'm sure you can combine these examples.

Good luck. Don't be afraid of Servlets they are your friend. You'll  
certainly want to know them if you need to do any binary content.

Regards,
Dave

On Jun 3, 2008, at 10:15 AM, Álvaro Morillas (Sortes Ing. Inf. S.L.)  
wrote:

> Although I don't use servlets, only jsp's, it's a solution I've  
> thought,
> using a log taglib. The problem is that I must insert the code in  
> every jsp
> and it's painful XD
>
> I was looking for an easier solution if it's available.
>
> Thanks anyway :)
>
>
>
> Álvaro Morillas Correa
> VicioJuegos.com - Sortes Ing. Inf., S.L.
>
> Plaza Mayor, 25, 1º, Of. 9-B
> 28911 Leganés (Madrid)
> Teléfono: 916943388 – Móvil: 617315926
> Horario: L-J: 9:00-14:00, 15:00-18:30 | V: 9:00-15:00
>
>
> -----Mensaje original-----
> De: Jim Cox [mailto:shakahshakah@gmail.com]
> Enviado el: martes, 03 de junio de 2008 16:30
> Para: Tomcat Users List
> Asunto: Re: Requests being processed at a certain moment
>
> I use a filter servlet to log entry/exit timestamps for requests  
> along with
> some shell scripting to process the logs looking for "still open"  
> requests.
> I've been using it for over a year for a production site, it's been  
> very
> useful for debugging unexplained slowdowns, hangs, etc.
>
> Filter is pretty simple, essentially:
>
> public void doFilter(...) {
>  int request_id = ++s_request_id ;
>  long lStart = System.currentTimeMillis() ;
>  logger_.info(request_id + " processing request for '" +  
> sRequestedUrl +
> "'") ;
>  try {
>    fc.doFilter(request, response) ;
>  }
>  finally {
>    logger_.info(request_id + " processed in " +  
> (System.currentTimeMillis()
> - lStart) + " msec") ;
>  }
> }
>
>
> On Tue, Jun 3, 2008 at 10:15 AM, Álvaro Morillas (Sortes Ing. Inf.  
> S. L. ) <
> amorillas@sortes.com> wrote:
>
>> Hi everyone. This is my first post in this group. I hope this  
>> question
>> hasn't been answered before.
>>
>>
>>
>> I have a problem with my web application. It is growing and in  
>> certain
> peak
>> moments the server gets very busy. I work with Tomcat 5.5 and IIS.  
>> I think
>> the problem is within my programming (not configuration). Because  
>> of that
>> I'm trying to see what requests are being processed in a certain  
>> moment by
>> Tomcat and for how long they've been there so I can tune them.
>>
>>
>>
>> Is there any application I can use to see that? Or I have to use  
>> the logs
>> and analize them in any way?
>>
>>
>>
>> I hope there is an easy solution for my problem.
>>
>>
>>
>> Thanks in advance.
>>
>>
>>
>> --------------------------------------------------------
>>
>> Álvaro Morillas Correa
>>
>> Sortes Ingeniería Informática, S.L.
>>
>> http://www.sortes.com
>>
>> Pza. Mayor, 25, Of. 9-B - 28911 Leganés (Madrid)
>>
>> Horario: L-J: 9:00-14:00 15:00-18:30 V: 9:00-15:00
>>
>> Tfno: 91 694 33 88 Fax: 91 693 10 47
>>
>> --------------------------------------------------------
>>
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message