Learning the path of the servlet--javax-servlet not exist

Source: Internet
Author: User

I'm compiling a Java file with the Javax.servlet package provided under a servlet rookie tutorial, and the mutation is wrong,

Import java.io.*;
Import javax.servlet.*;
Import javax.servlet.http.*;


public class HelloWorld extends HttpServlet {
public void doget (HttpServletRequest request, httpservletresponse response)
Throws IOException, Servletexception
{

The following issues occur:

Helloworld.java:2: Package Javax.servlet does not exist
Import javax.servlet.*;
^
Helloworld.java:3: Package javax.servlet.http does not exist
Import javax.servlet.http.*;
^
Helloworld.java:6: Symbol not found
Symbol: Class HttpServlet
public class HelloWorld extends HttpServlet {
^
Helloworld.java:7: Symbol not found
Symbol: Class HttpServletRequest
Location: Class HelloWorld
public void doget (HttpServletRequest request, httpservletresponse response)
^
Helloworld.java:7: Symbol not found
Symbol: Class HttpServletResponse
Location: Class HelloWorld
public void doget (HttpServletRequest request, httpservletresponse response)
^
Helloworld.java:8: Symbol not found
Symbol: Class Servletexception
Location: Class HelloWorld
Throws IOException, Servletexception

The reason is that the Java compiler did not find the package javax.servlet.

Workaround:

Copy a Servlet-api.jar package from the Tomcat Lib directory to the "Jdk\jre\lib\ext" directory

In the case of cases where the package is not found, it is possible to put the found package under Jdk\jre\lib\ext and then compile it to pass.

Learning the path of the servlet--javax-servlet not exist

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.