• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet filters and logging

 
kiran kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
 
Bhushan Jawle
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • 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
  • 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: 249
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Let me try using the extension....
no, the images dont have hyperlink
thanks for ur suggestion Bhushan!
-Kiran
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic