Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
464 views
in Technique[技术] by (71.8m points)

jsp - Why Tomcat gives error when importing a plain object?

Tomcat 8.5.35 gives a strange error when trying to initialize a simple object inside a JSP page.

Here is the error:

enter image description here

and here is the JSP:

<%@page import="dust.One"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
        <%
            One o = new One("Joe");
            out.println(o.getName());
        %>      
    </body>
</html>

and here is the class

package dust;

public class One {
    String name;

    public One(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }        
}

I have to mention that the same webapp is working just fine in Jetty (9.4.35).

What can it be?

--Edit-- It seems that if the app is packed as .war and deployed on Tomcat through it's Manager web interface it's working fine.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The problem vanished with the upgrade of Netbeans to version 13.

As @Bogdan mentioned I think this comes more from Netbeans plugins than from the Tomcat itself.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...