3

If in a JSP page I create a new file only giving it's name, it's created in the /bin directory of TOMCAT folder, rather in the same folder of the .jsp.

I'm not sure why this happens, seems to be not intuitive.

makakko
  • 357
  • 5
  • 11

1 Answers1

3

It's definitely intuitive, as the current directory of the running process is the bin folder.

You can try something like:

ServletContext context = session.getServletContext();
String realContextPath = context.getRealPath(request.getContextPath()); 
Anon
  • 1,290
  • 2
  • 16
  • 24
  • 5
    It's not quite that simple. The working directory will be whatever directory Tomcat was started from, not necessarily Tomcat's bin directory. If I go to Tomcat's root directory (i.e. the directory containing bin) and run "bin/startup.sh", the working directory will be Tomcat's root directory. – haydenmuhl Aug 15 '11 at 06:39