• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getServletContext() error

 
Damodara Reddy
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Joan Horta Tosas
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried with the updated version(servlet-api.jar) also, still I am getting the same error.
 
Abdul Kader
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you using IDE for this code development
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic