intellij idea - Get Application path in grails controller -


i'm use intellij idea grails project.

i want upload, user profile picture project directory. e.g. e:\myproject\useruploads

currently i'm trying path using following code

def filepath = request.getsession().getservletcontext().getrealpath("/") 

but when print filepath get:

c:\users\rahul.mahadik\appdata\local\temp\tomcat-docbase.2236924879274963579.8080\

also tried "servletcontext.getrealpath("/")" path of current directory getting same path above

thanks

you should understand flow of building , running web application in grails.

when start run-app command, grails compiles code , creates war file - web application archive. in order run war file need web server. grails has embedded tomcat server, gets war file , deploys tomcat.
tomcat has own folder web application archive deployed. path application path folder tomcat server running application. that's why see

c:\users\rahul.mahadik\appdata\local\temp\tomcat-docbase.2236924879274963579.8080\

obviously, tomcat has no idea project located. can't path when application running.

it's common practice make path file storage configurable. can idea how use external config file in topic: how use external .groovy config file in grails 3


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -