Silly question...

W

Wandy Tang

Hi All,

I have this in a java.

import javax.servlet.*;
getServletContext().getRealPath("/");

it returns compiled error:
cannot resolve symbol
symbol : method getServletContext()

Anything wrong with that?

Regards,
Wandy
 
A

Alex Zorin

Well, make sure the case of the text is right, or it wont work...

Also, are you sure you've imported right class? Check the docs
 
T

Tor Iver Wilhelmsen

Wandy Tang said:
I have this in a java.

import javax.servlet.*;
getServletContext().getRealPath("/");

No, you don't, because that won't compile.
symbol : method getServletContext()

Anything wrong with that?

Well, yes, if the class you're in doesn't define or inherit a method
by that name.

An example of a class that has such a method is
javax.servlet.GenericServlet, and its commonly used subclass
javax.servlet.http.HttpServlet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top