views:

30

answers:

1

I want to use a File object to read a local file in the same directory as a groovlet. However, using a relative path to the file (either "example.txt" or "./example.txt") doesn't do the trick. If I give it an absolute path (e.g., "/example.txt"), then it works.

Is there any way to get the working directory or context path of the groovlet programmatically?

A: 
new File("${request.getContextPath()}/example.txt")
Aaron Saunders
Great! But what I was actually going for is `getRealPath('/')`. Your answer pointed me in the right direction. Thanks!
Steve Nay