Howdy,

>i y make: String whereIs = getServletContext().getRealPath("/");
>
>appears this error:
> utils/filtroSessiones.java [50:1] cannot resolve symbol
>symbol  : method getServletContext  ()
>location: class utils.filtroSessiones
>        String whereIs=getServletContext().getRealPath("/");
>                            

The servlet context is only accessible within servlets (and filters,
etc.).  It's not going to be accessible within your utils class unless
you pass a reference to it.

Perhaps you could post your complete use-case: why are you trying to get
the real path, when you need it, what you need it for.  

If the directory you want contains configuration information, or it's a
destination for log files, etc, you could pass it as a context-param.
For example, add the following to your web.xml:
<context-param>
  <param-name>myDirectory</param-name>
  <param-value>/home/user</param-value>
</context-param>

Then in your servlets, 
String myDirectory =
getServletContext().getInitParameter("myDirectory");

This is probably better than using getRealPath().

Alternatively, if you need to read from this directory, consider using
getResource() or getResourceAsStream() (which are also in the servlet
context class).

Yoav Shapira
Millennium ChemInformatics

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to