javax类找不到?

jxyuhua 2003-07-23 04:26:53
/* $Id: HelloWorldExample.java,v 1.2 2001/11/29 18:27:25 remm Exp $
*
*/

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
* The simplest possible servlet.
*
* @author James Duncan Davidson
*/

public class HelloWorld extends HttpServlet {


public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
ResourceBundle rb =
ResourceBundle.getBundle("LocalStrings",request.getLocale());
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<html>");
out.println("<head>");

String title = rb.getString("helloworld.title");

out.println("<title>" + title + "</title>");
out.println("</head>");
out.println("<body bgcolor=\"white\">");

// note that all links are created to be relative. this
// ensures that we can move the web application that this
// servlet belongs to to a different place in the url
// tree and not have any harmful side effects.

// XXX
// making these absolute till we work out the
// addition of a PathInfo issue

out.println("<a href=\"/examples/servlets/helloworld.html\">");
out.println("<img src=\"/examples/images/code.gif\" height=24 " +
"width=24 align=right border=0 alt=\"view code\"></a>");
out.println("<a href=\"/examples/servlets/index.html\">");
out.println("<img src=\"/examples/images/return.gif\" height=24 " +
"width=24 align=right border=0 alt=\"return\"></a>");
out.println("<h1>" + title + "</h1>");
out.println("</body>");
out.println("</html>");
}
}



这是Tomcat 4.1自带的文件,我重新编译的时候却提示

HelloWorld.java 8:package javax.servlet.http does not exit
import javax.servlet.http.*;

我用的是JDK1.41 为什么会出现这样的情况呢?要如何解决?请各位帮我。
...全文
90 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hodex 2003-07-23
  • 打赏
  • 举报
回复
装了j2ee里面也会有的
star821116 2003-07-23
  • 打赏
  • 举报
回复
把servlet.jar放到C:\JDK\jre\lib\ext就OVER了
zuoyangguang 2003-07-23
  • 打赏
  • 举报
回复
在Tomcat 4.1\common\lib下有个servlet.jar,添加到你的编译环境中去
  • 打赏
  • 举报
回复
CLASSPATH变量要加上tomcat的common/lib/servlet.jar文件.

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧