How to get Project path in Vaadin

How to get Project path in Vaadin

(ie., C:/Tomcat/webapps/project)

Can I get project path in vaadin (ie., …/webapps/project/)

You would do it just like you’d do it in any other Java web app, which is to say “it depends.” In any case, there’s nothing specific to Vaadin about finding where your application is running. You could add an app lifecycle listener to get the
ServletContext
object or implement Vaadin’s
HttpServletRequestListener
and get it from the http session. Then you could try calling getRealPath(“/”) on it. But that could vary depending on how you’ve deployed the app.

You could try using the
ServletContext.TEMPDIR
property from the servlet context, but that may not be exactly what you want.

Can you tell us what you’re trying to do? If it’s loading some other resource from your web app, there are other ways to do this without knowing where your app is deployed. You can always set an init parameter in web.xml to some absolute path if you’d like and read that. With more info on what you’re trying to do, it might be easy to help you.


Here’s a decent intro
on Java web apps, their lifecycle, etc.

Cheers,
Bobby