简体   繁体   中英

package javax.servlet does not exist on Tomcat

I am writing JApplet in Netbeans. My applet is working, so I decide to add servlet because I want to have log in/out. When I added servlet to my project as follows:

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

I had the following errors:

error: package javax.servlet does not exist 
import javax.servlet.ServletException;
error: package javax.servlet.http does not exist
import javax.servlet.http.HttpServlet;

Apache Tomcat is working.

Add servlet jar to the classpath in your IDE. Your webcontainer will provide it at runtime. You don't have to bundle it in your WAR

I found this solution here

Under Libraries Folder in the Project Window, Right-click and "Add Library...", then choose Java EE web 8 API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM