Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP and Files

 
Baba Bizlowsky
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Me again.

My JSP page has to log something in the file. For that purpose I have created a custom MyLogger class which has a static logging method. It receives a string, a name it should use for the file and it should create a file and put the string with logging info in it.

This MyLogger class, of course, resides in a WEB-INF/classes directory.

Upon testing it, however, I saw that the file gets created inside %TOMCAT_ROOT%/bin directory. Why? I thought that it would be created in an approppriate webapp directory, not there of all places...

How should I handle this?

Thanks in advance. Cheers!
 
Lavern Matthew
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the TOMCAT_HOME/bin is the current working directory. Take a look at
ServletContext.getRealPath(java.lang.String)
 
Lavern Matthew
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or better yet: http://javaboutique.internet.com/articles/LogwithJSP/
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic