How to get rid of "javax.servlet.jsp.PageContext cannot be resolved to a type" in jsp page with Eclipse?

Samuel Rossille picture Samuel Rossille · Apr 24, 2013 · Viewed 13.3k times · Source

I have this weird error in a .jsp page in eclipse:

javax.servlet.jsp.PageContext cannot be resolved to a type

My project is a maven project imported into "as an existing maven project" into juno with m2e and m2e-wtp plugins installed.

Is this a bug of the m2e plugins ? If yes, what's a possible workaround to get rid of this error (and the red mark in the workspace explorer) ?

Otherwise, do I need to "tell" to maven that my project contains jsp pages ? And hopefully, the m2e plugin will add the right library to the classpath. If yes, how ?

enter image description here

Answer

Nav picture Nav · Aug 28, 2014

The solution that worked for me, is given in this answer. Go to project properties > Targeted runtimes > Select the checkbox for a runtime (Apache Tomcat 7 in my case).
That's all. Just build the project now and everything will be fine.