javax.servlet.ServletException cannot be resolved to a type in spring web app [duplicate]
I am developing web app using spring frame work, but i am getting following error in some of the jsp pages.
javax.servlet.ServletException cannot be resolved to a type
I have included servlet-api
also but still same error message is displaying. How to over come this problem?
Solution 1:
I guess this may work, in Eclipse select your project → then click on project menu bar on top → goto to properties → click on Targeted Runtimes → now you must select a check box next to the server you are using to run current project → click Apply → then click OK button. That's it, give a try.
Solution 2:
It seems to me that eclipse doesn't recognize the java ee web api (servlets, el, and so on). If you're using maven and don't want to configure eclipse with a specified server runtime, put the dependecy below in your web project pom:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version> <!-- Put here the version of your Java EE app, in my case 7.0 -->
<scope>provided</scope>
</dependency>
Solution 3:
STEP 1
Go to properties of your project ( with Alt+Enter or righ-click )
STEP 2
check on Apache Tomcat v7.0 under Targeted Runtime and it works.
source: https://stackoverflow.com/a/9287149
Solution 4:
Add the server(tomcat) from Right click on the Project and select the "Properties" go to "Project Factes" "Runtime tab" other wise "Target Runtime"
if it is maven pom.xml issue, try added this to the pom.xml
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>
it will solve the issue.