Re: Help with Java servlet : getServletContext().



kaeli <tiny_one@xxxxxxxxxxxxxxxxxx> said:
>In article <1114785464.432939.282130@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, vmswar2
>@yahoo.com enlightened us with...
>> I am newbie to Java, am trying to get a program working, and I have
>> imported the java packages below along with many other imports :
>> import javax.servlet.GenericServlet;
>> ....
>> xsltFile = new File(getServletContext().
>
>What are you getting the servletContext FROM? ;)
>
>someServlet.getServletContext()
>
>Probably, depending on where this statement is running from, you want
>this.getServletContext()
>
>You can call a method on nothing.

What?

'this.foo()' is equivalent to 'foo()' - at least in all cases I can imagine
(and please educate me if there are cases where this isn't so!). It will
always call method 'foo()' either on the current class, or on the closest
superclass implementing the method.

There are cases where you might need an explicit 'this.' for referencing
instance variables (where you have a local variable of the same name,
shadowing the instance variable), but for method calls, 'this.' is always
superfluous.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
.



Relevant Pages