Tag Archives: HTTP Status 500 – Unable to compile class for JSP

HTTP Status 500 – Unable to compile class for JSP settlement program

Don’t panic in case of data tilt, teach you to easily obtain the slope of table tilt>>>

Analysis of the problems:

Maven is used to manage jar packages. Therefore, when spring MVC framework is used, jar packages such as servlet-api.jar and jsp-api.jar will be manually configured into the project. Otherwise, some JSPS will heartlessly report errors (no corresponding jar package can be found). However, when servlet-api.jar is configured, it may conflict with jar packages in tomcat container, resulting in the above problems, The JSP cannot be found. The problem will only appear in tomcat8 or above, and there is no problem in tomcat7 or below

So if you use tomcat8 and later children’s shoes, you may use the following solutions

Solution:

Solution 1: after publishing the project, remove the servlet-api-xxx.jar from the webapps directory, and restart Tomcat. Remember to restart Tomcat instead of publishing the project

Scheme 2: add server library to the project directly

Right click on the project — > build Path –> Add Library –> Server Library –> Apache Tomcat v8.0 (provided Tomcat 8 and later are integrated into eclipse, or MyEclipse, or other ides used)

the above two solutions are always a little palliative for using Maven projects. The purpose of using Maven is to completely control the dependency of jar packages. If jars need to be added or deleted manually at that time, it will be very troublesome in team collaboration, so we need to provide another solution here

Scheme 3: add scope and limit it to provided

Add provided restriction:

The scope provided by the container or JDK indicates that the dependent package has been provided by the target container (such as Tomcat) and JDK. It is only loaded and used in the compiled classpath and will not be included in the target package when it is packaged. The most common jar packages are servlet API and JSP API related to J2EE specification, which are generally provided by servlet container and need not be packaged into war package. If they are not configured as provided, these packages will be packaged into project war package, and there will be conflicts in Tomcat6 and above versions, and the program will not run normally

<dependency>  
    <groupId>tomcat</groupId>  
    <artifactId>servlet-api</artifactId>  
    <version>5.5.23</version>  
    <scope>provided</scope>  
</dependency>