aspose file tools*
The moose likes Servlets and the fly likes servlet filters and logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet filters and logging" Watch "servlet filters and logging" New topic
Author

servlet filters and logging

kiran kumar
Greenhorn

Joined: Jun 29, 2002
Posts: 5
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

Joined: Nov 22, 2001
Posts: 249
If you could specify where the code for logging is invoked from, that will clarify the problem further.
Thanks.
kiran kumar
Greenhorn

Joined: Jun 29, 2002
Posts: 5
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

Joined: Nov 22, 2001
Posts: 249
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

Joined: Jun 29, 2002
Posts: 5
Let me try using the extension....
no, the images dont have hyperlink
thanks for ur suggestion Bhushan!
-Kiran
 
 
subject: servlet filters and logging
 
Similar Threads
Calendar.roll() questions
Oracle 9i AS and struts!! Urgent
question on servlet-mapping
HFJS ,chapter 12 -fatal error
Logging ...