• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servlet filters and logging

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Gurus,
I am trying to log IP,date,URL when someone accesses my servlet using a Filter..
Everything works fine except that my servlet has multiple images and the log is getting filled with multiple entries, one entry for each image and html file served by the web container.
How can I avoid this to have only one entry per client request for servlet..
currently i am doing
context.log(date+getRequestURL()+getRemoteAddress())
My current log looks like
2002-12-10 04:50:39 -http://IP:8888/ra/Servlet1--< RemoteAddress>
2002-12-10 04:50:39 -http://IP:8888/ra/image1--< RemoteAddress>
2002-12-10 04:50:39 -http://IP:8888/ra/image2--< RemoteAddress>

I want to see only one entry for the Servlet1 and dont want to see the entries for image in the log...
Would appreciate any ideas..
thanks
Kiran
 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you could specify where the code for logging is invoked from, that will clarify the problem further.
Thanks.
 
kiran kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
the filter is invoked for all components with <url-pattern> of /ra/* in web.xml
the <filter-name>,<filter-class>and <filter-mapping> are defined in the web.xml file...
This filter does pre-processing for any servlet accessed in the application
Pl let me know if u need more info to clarify
thanks
 
Bhushan Jawle
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your log entries
2002-12-10 04:50:39 -http://IP:8888/ra/Servlet1--< RemoteAddress>
2002-12-10 04:50:39 -http://IP:8888/ra/image1--< RemoteAddress>
2002-12-10 04:50:39 -http://IP:8888/ra/image2--< RemoteAddress>
do fit the pattern specified for invocation of filter. Have you tried using commands like "someCommandName.someExtension" and map the servlet by "/ra/*.someExtension" instead of using hyperlinks directly ? That should solve your problem.
I am assuming that image1 and 2 are embedded somewhere in you page being served.
However I am not sure why image1 and image2 appear as seperate commands( you haven't listed them in hyperlink directly right ? )
 
kiran kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me try using the extension....
no, the images dont have hyperlink
thanks for ur suggestion Bhushan!
-Kiran
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic