users@glassfish.java.net

Re: Glassfish: how to get application root (such as Tomcat ${APP

From: <forums_at_java.net>
Date: Mon, 16 Jan 2012 10:24:10 -0600 (CST)

[quote=swchan2]If you have a HttpServletRequest, then you can access the
ServletContext by request.getServletContext() then you get call
getRealPath("/").[/quote]

Nope.

I'm in a plain Java class with a method "foo".

  From a JSP page "bar.jsp" I call "myclass.foo()".

I believe I could get HttpServletRequest by "bar.jsp" and pass it as a
parameter to "myclass.foo()"; but I respect Java language too much to
believe so tight-coupling a trick has to be used.

Also, I need and put application root in a configuration file; so, I need
and know, if there's a Glassfish environment variable equivalent to Tomcat's
${APP_ROOT}.


--
[Message sent by forum member 'paolod']
View Post: http://forums.java.net/node/882705