Don't understand code completion for JSP

Hi,

I'm new to this JSP malarky, so please bear with me ...

We have a whole load of JSPs in our system which all compile (Tomcat
4.0.5). However, I came across one line which was marked red in Idea:
String path = getServletContext().getRealPath(jspurltest);
It didn't like the "getServletContext" call.

Sure enough, if I try typing "this." and then hit ctrl-space to see the
methods available, I get the following list of methods:
_jspService(HttpServletRequest, HttpServletResponse)
destroy()
getServletConfig()
getServletInfo()
init(ServletConfig)
jspDestroy()
jspInit()
service(ServletRequest, ServletResponse)

I did a bit of research, this list of methods corresponds to the
interface HttpJspPage in the 1.3 specs. Looks like Idea doesn't know (or
isn't allowing itself to know) that the implementation is a
GenericServlet, is that right?

If so, is the above call illegal according to the specs? Can I get round
it with something like
String path =
((GenericServlet)this).getServletContext().getRealPath(jspurltest);

It seems a bit strange to be casting "this"!

Thanks for your advice,
Robbie

Please sign in to leave a comment.