Tag Archives: jsp

[Solved] IDEA: JSP Could Not Use session Build-in Object

Problem description

Cause

since the author uses Tomcat 10, the servlet dependency used is Jakarta Servlet. For details, see building a servlet using Tomcat 10. An error is reported: class XXX is not a servlet. The error is because the servlet API package is not imported.

Solution:

Import servlet API dependencies.

<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>4.0.1</version>
</dependency>

Springboot always reports an error when importing JSP dependencies

Paste my own POM code first:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
 4     <modelVersion>4.0.0</modelVersion>
 5     <parent>
 6         <groupId>org.springframework.boot</groupId>
 7         <artifactId>spring-boot-starter-parent</artifactId>
 8         <version>1.5.6.RELEASE</version>
 9         <relativePath/> <!-- lookup parent from repository -->
10     </parent>
11     <groupId>com.sblueice</groupId>
12     <artifactId>demo</artifactId>
13     <version>0.0.1-SNAPSHOT</version>
14     <packaging>war</packaging>
15     <name>demo</name>
16     <description>Demo project for Spring Boot</description>
17 
18     <properties>
19         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
21         <java.version>1.8</java.version>
22     </properties>
23 
24     <dependencies>
25         <dependency>
26             <groupId>org.springframework.boot</groupId>
27             <artifactId>spring-boot-starter-web</artifactId>
28         </dependency>
29         <dependency>
30             <groupId>javax.servlet</groupId>
31             <artifactId>javax.servlet-api</artifactId>
32             <scope>provided</scope>
33         </dependency>
34         
35          <!--sppourt jsp -->
36         <dependency>
37               <groupId>javax.servlet</groupId>
38               <artifactId>jstl</artifactId>
39               <version>1.2</version>
40         </dependency>
41 
42        <dependency>
43         <groupId>com.mchange</groupId>
44         <artifactId>c3p0</artifactId>
45         <version>0.9.5.2</version>
46     </dependency>
47         <!-- Setting it to provided will exclude the package when packaging, as it is not needed to be put into a standalone tomcat to run. -->
48         <dependency>
49             <groupId>org.springframework.boot</groupId>
50             <artifactId>spring-boot-starter-tomcat</artifactId>
51             <scope>provided</scope>
52         </dependency>
53         <dependency>
54             <groupId>org.springframework.boot</groupId>
55             <artifactId>spring-boot-starter-test</artifactId>
56             <scope>test</scope>
57         </dependency>
58         <dependency>
59             <groupId>org.springframework.boot</groupId>
60             <artifactId>spring-boot-devtools</artifactId>
61             <optional>true</optional>
62         </dependency>
63                 <dependency>
64             <groupId>org.springframework.boot</groupId>
65             <artifactId>spring-boot-starter-jdbc</artifactId>
66         </dependency>
67         <dependency>
68             <groupId>org.mybatis.spring.boot</groupId>
69             <artifactId>mybatis-spring-boot-starter</artifactId>
70             <version>1.3.2</version>
71         </dependency>
72         <dependency>
73             <groupId>mysql</groupId>
74             <artifactId>mysql-connector-java</artifactId>
75             <scope>runtime</scope>
76         </dependency>
77 
78     </dependencies>
79 
80     <build>
81         <plugins>
82             <plugin>
83                 <groupId>org.springframework.boot</groupId>
84                 <artifactId>spring-boot-maven-plugin</artifactId>
85             </plugin>
86            <plugin>
87                  <groupId>org.apache.maven.plugins</groupId>
88                  <artifactId>maven-compiler-plugin</artifactId>
89                  <version>3.1</version>
90                  <configuration>
91                      <source>1.8</source>     
92                      <target>1.8</target>     
93                  </configuration>
94            </plugin>
95         </plugins>
96     </build>
97 
98 </project>

 

Modification 1: first, the parent class depends on the version number, which is changed from 2.0.1 to 1.5.6 according to Baidu

  Modification 2: again, the error of importing JSP dependency: missing artifact org.apache.tomcat.embedded: Tomcat embedded Jasper: jar: 8.5.16

If you don’t add a JSP dependency, you can download the JSP file directly and report an error if you add it. Now I’m confused

Record it, there is a great God answer is more desirable

October 10, 2019 has been solved:

Finally, it was found that there was a problem with the version. It was tested from 1.5.6 to 2.0.3. It was found that there was no problem with the version 2.0.3, which proved that this version was suitable for my computer and my eclipse

Operating system: win10 64 bit
Eclipse: Version: 2019-09 R (4.13.0)
Maven should be 3.5.0

1. The following are the dependencies required by JSP :

    <!--servlet begin -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <!--servlet end -->
    <!--jsp begin -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    <!--jsp end -->
    <dependency>
      <groupId>org.apache.tomcat.embed</groupId>
      <artifactId>tomcat-embed-jasper</artifactId>
      <scope>provided</scope>
    </dependency>

 

2. Add the prefix in application.yml

  spring:
    mvc:
      view:
        prefix: /WEB-INF/views
        suffix: .jsp

—-Encourage with you

JSP Web Error:The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path

problem description

for a new web project, the index.jsp page reports an error: the superclass “javax. Servlet. Http. Httpservlet” was not found on the Java build path
as shown in the figure:

processing method
right click build path configure build path, under libraries, click add variable

select server runtime, click Next

select tomcat, click Finish

and finally click OK

processing results

JSP Page The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path

When you encounter this problem, it may be a new project, and the path of Tomcat is not configured

Firstly add Tomcat

Choose the version of Tomcat to add. I use 7.0 here

After that

Right click the project — > Build Path –> Configure build path –> Libraries –> Add Library –> Server Runtime–> tomact

MyEclipse open JSP report unhandled event loop exception no more handles error

When using MyEclipse, an unhandled event loop exception no more handles error pops up. Click OK, and then close the workspace. After restarting the workspace, as soon as you click the JSP file, the error will pop up

Search for answers on the Internet and say to change the default JSP editing tool. The method is as follows:

windows -> preferences -> General -> Editors -> File associations to change the default editing tool for *. JSP files

This method has been tried, but it still has no effect

Continuing to search for answers, I found that I wanted to change/delete the workbench.xml file in the workspace. I tried to delete several newly added JSP/JS files in the workspace. After restarting, the problem remained the same. Later, I directly deleted the file. After restarting, I would not report the error. Deleting the file did not cause any negative impact

Workbench.xml file location: e::?MyEclipse_ workspace\.metadata\.plugins\org.eclipse.ui.workbench

Find MyEclipse workspace and delete it