Manning's Countdown to 2014
. Use discount code crdotd14 all month for 50% off every deal.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Writing to a file through Servlet
Joined: Jan 29, 2006
Mar 10, 2006 17:06:00
I want to log all the events in the application into a file log.txt
How can a write to a file through a
. I do need the absolute path of the file. like for example the file is in docs folder of the base directory of my application project.
How can i write to this file log.txt through my Servlet?
Thanking in advance,
Joined: Nov 15, 2004
Mar 10, 2006 22:32:00
has a log methods with which you can log events to files.
You also get log methods in your servlet through GenericServlet-->
For absolute path you can use getRealPath() from
. But this method will return
if you pack your application as a war file.
Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1
JSTL Tag Documentation
Joined: Aug 15, 2004
Mar 11, 2006 06:41:00
In addition, Filters meant for these kinda stuff. You can also go for some libraries like Log4J or jakarta commons logging. And you can always search the web for some working examples.
subject: Writing to a file through Servlet
html vs servlet
Any File(URI uri) example?
XML - DTD and Doctype in a Java App.
Log file no longer logging...
making use of servlet through WEB-INF
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013