i am trying to load, to get , the real path in the disk (/home/user/)
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("/");
                            ^
1 error

Can you help me?
thanks


----- Original Message -----
From: "Shapira, Yoav" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Monday, December 16, 2002 3:05 PM
Subject: RE: error in one servlet with the


Howdy,

>i i write in one servlet this:
>String whereIs = ((ServletContext)request).getRealPath("/");
>in tomcat appears this error, can any body help me? Thanks

What are you trying to do? ;)

A request is not a context.  So what you're doing is an invalid cast and
the JVM correctly throws an exception at runtime.

Assuming the above code is in a servlet, you can just do:
String whereIs = getServletContext().getRealPath("/");
To get the "real" (file) path to the docBase of your webapp.  As the
code suggests, this path is request-independent.

Note that this wouldn't work if you're running from a packed .war
archive.

Yoav Shapira
Millennium ChemInformatics

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




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

Reply via email to