servlet无法编译帮忙看看

djsjeff 2003-04-06 11:34:39
HelloWorldExample.java

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 HelloWorldExample 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>");
}
}



出错信息
--------------------Configuration: j2sdk1.4.1_01 <Default>--------------------
C:\jakarta-tomcat-4.1.18\webapps\examples\WEB-INF\classes\HelloWorldExample.java:8: package javax.servlet does not exist
import javax.servlet.*;
^
C:\jakarta-tomcat-4.1.18\webapps\examples\WEB-INF\classes\HelloWorldExample.java:9: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
C:\jakarta-tomcat-4.1.18\webapps\examples\WEB-INF\classes\HelloWorldExample.java:17: cannot resolve symbol
symbol : class HttpServlet
location: class HelloWorldExample
public class HelloWorldExample extends HttpServlet {
^
C:\jakarta-tomcat-4.1.18\webapps\examples\WEB-INF\classes\HelloWorldExample.java:20: cannot resolve symbol
symbol : class HttpServletRequest
location: class HelloWorldExample
public void doGet(HttpServletRequest request,
^
C:\jakarta-tomcat-4.1.18\webapps\examples\WEB-INF\classes\HelloWorldExample.java:21: cannot resolve symbol
symbol : class HttpServletResponse
location: class HelloWorldExample
HttpServletResponse response)
^
C:\jakarta-tomcat-4.1.18\webapps\examples\WEB-INF\classes\HelloWorldExample.java:22: cannot resolve symbol
symbol : class ServletException
location: class HelloWorldExample
throws IOException, ServletException
^
6 errors

Process completed.

他说包不存在,是不是编译servlet要下载servlet开发工具包阿
...全文
52 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
djsjeff 2003-04-06
行了我在jcrator里刚才没有加谢谢 Mailbomb(网络咖啡)
回复
djsjeff 2003-04-06
我加了重新启动再试还是不行我得
classpath为
.;c:\j2sdk1.4.1_01\lib\tools.jar;c:\j2sdk1.4.1_01\lib\dt.jar;C:\jakarta-tomcat-4.1.18\common\classes;C:\jakarta-tomcat-4.1.18\common\lib;C:\jakarta-tomcat-4.1.18\common\lib\servlet.jar
有问题吗
谁可以编译的巴你们的classpath写出来看看好吗
回复
网络咖啡 2003-04-06
把Tomcat下面的servlet.jar添加到classpath中去
回复
djsjeff 2003-04-06
大家帮忙看看谢谢大家了
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2003-04-06 11:34
社区公告
暂无公告