Reputation: 967
I want to get application path in my application, but I haven't found any way. If anyone knows how can I get application path in my app, It would be great.
Many thanks,
Upvotes: 4
Views: 7042
Reputation: 7713
I think , most of the time was difficult to find the path inside gsp.
but , you can use this :
var path = "${resource()}"+"/mycontroller/myaction" ;
gives you the path of the application.
Inside controller like when you need to upload file :
def webRootDir = servletContext.getRealPath("/")
def userDir = new File(webRootDir, "/payload/${session.user.login}")
userDir.mkdirs()
uploadedFile.transferTo( new File( userDir, uploadedFile.originalFilename))
Upvotes: 1
Reputation: 1749
If you want to get absolute path for application, you can get like this.
String applicationPath = request.getSession().getServletContext().getRealPath("")
It will provide absolute path for application.
Upvotes: 7