aspose file tools*
The moose likes Servlets and the fly likes getServletContext() error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "getServletContext() error" Watch "getServletContext() error" New topic
Author

getServletContext() error

Damodara Reddy
Ranch Hand

Joined: Feb 09, 2007
Posts: 44
Hi,

While compiling my application I am getting the error saying " can not resolve symbol getServletContext() in HttpSession.
I have set the classpath to servlet-api.jar and servlet.jar

Please help me in resolving the above problem.

Thanks & Regards
Damodar Reddy G


Damu
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is a getServletContext method in HttpSession.
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSession.html

If the compiler found HttpSession then it's probably not a classpath issue.
Check your spelling.

You didn't, by any chance, name one of your objects HttpSession, did you?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Joan Horta Tosas
Ranch Hand

Joined: Feb 01, 2007
Posts: 59
As it says in the API doc, this method appeared in Servlet API 2.3, which is covered on J2EE 1.3. Are you using an updated servlet-api.jar and servlet.jar (for example, from Tomcat 4.1 or 5.x or 6.x)? If you're developing using an IDE, look for the target J2EE, maybe it's configured by default to 1.2 or 1.1...
Damodara Reddy
Ranch Hand

Joined: Feb 09, 2007
Posts: 44
I have tried with the updated version(servlet-api.jar) also, still I am getting the same error.
Abdul Kader
Ranch Hand

Joined: Apr 11, 2007
Posts: 115
are you using IDE for this code development
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getServletContext() error
 
Similar Threads
How to get context-param from web.xml in struts app
JSP using getServletContext Error
FileNotFoundException is thrown when i try to read a file?
The method getServletContext() is undefined for the type error in jsp page in Eclipse
RequestDispatcher foward cross web application error