There is no javax. servlet package in JDK. What should I do when it is used in the program ??

Source: Internet
Author: User

There is no javax. servlet package in JDK. The following program is used when it is used:
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
{
Response. setcontenttype ("text/html ");
Printwriter out = response. getwriter ();
Out. println ("<HTML> ");
Out. println ("Out. println ("<title> Hello world! </Title> ");
Out. println ("Out. println ("<body> ");
Out. println ("Out. println ("</body> ");
Out. println ("}
}

When javac helloworld. Java is executed in the command line, the error code/helloworld. Java: 2:? is displayed :? Software Package? Javax. servlet? Does not exist?
? Import? Javax. servlet .*;?
? ^?
? D:/tomcat? 5.5/webapps/root/sl_exp/P90/helloworld. Java: 3 :? Software Package? Javax. servlet? Does not exist?
? Import? Javax. servlet. HTTP ;?
And so on.

How can this problem be solved?
The answer is: in Tomcat under D:/tomcat 6.0/lib find the servlet-api.jar file, copy a copy, and then extract, it will find that there is javax this file, this file contains the Servlet File. Copy the Servlet File to lib under JDK, for example, C:/program files/Java/jdk1.6.0 _ 12/lib, then you can recompile it.

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.