You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Reynolds <ji...@gmail.com> on 2005/11/10 20:18:00 UTC

getRealPath() from Action class

In an Action class I am writing, I would like to be able to get the
real physical path to the web app. Eg: C:/webserver/webapp/instance

According to the docs, the request.getRealPath("instance") is going
away. It looks like the ServletContext would work, but I do not know
how to get the context from an Action class.


/java docs
public java.lang.String getRealPath(java.lang.String path)

Deprecated. As of Version 2.1 of the Java Servlet API, use
ServletContext.getRealPath(java.lang.String) instead.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: getRealPath() from Action class

Posted by Ed Griebel <ed...@gmail.com>.
in your action try:

ServletContext context = request.getSession().getServletContext();

-ed

On 11/10/05, Jim Reynolds <ji...@gmail.com> wrote:
> In an Action class I am writing, I would like to be able to get the
> real physical path to the web app. Eg: C:/webserver/webapp/instance
>
> According to the docs, the request.getRealPath("instance") is going
> away. It looks like the ServletContext would work, but I do not know
> how to get the context from an Action class.
>
>
> /java docs
> public java.lang.String getRealPath(java.lang.String path)
>
> Deprecated. As of Version 2.1 of the Java Servlet API, use
> ServletContext.getRealPath(java.lang.String) instead.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org