file writing

Hi,Can anyone tell me, how can i write a text file JSP, which is located in my "webapps/log/log.txt" location? Two line sample code to get ouput stream will be very helpful.Regards.Jahid
[214 byte] By [bdspidera] at [2007-11-27 5:36:43]
# 1

the getRealPath() method provided by ServletContext will convert a website relative path into a real location on disk. It will most likely help you in this case.

ServletContext application = getServletConfig().getServletContext();

String currentContextRoot = application.getRealPath("/");

String logFile = application.getRealPath("/log.txt");

From this string you can create a File object, and a FileWriter for it.

evnafetsa at 2007-7-12 15:07:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...