当前位置: 技术问答>java相关
我无法编译自己的servlet?? why!
来源: 互联网 发布时间:2015-02-23
本文导语: 一个很简单的程序!! 我用jdk1.3编译,出错! 是我环境没配好吗? 源代码如下: import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorldBean extends HttpServlet { public void doGet(HttpServletReque...
一个很简单的程序!!
我用jdk1.3编译,出错! 是我环境没配好吗?
源代码如下:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldBean extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
}
}
following is the Error Info:
////////////////////////////////////////////////////////////
HelloWorldBean.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
HelloWorldBean.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HelloWorldBean.java:5: cannot resolve symbol
symbol : class HttpServlet
location: class HelloWorldBean
public class HelloWorldBean extends HttpServlet {
^
HelloWorldBean.java:7: cannot resolve symbol
symbol : class HttpServletRequest
location: class HelloWorldBean
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
HelloWorldBean.java:7: cannot resolve symbol
symbol : class HttpServletResponse
location: class HelloWorldBean
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
HelloWorldBean.java:8: cannot resolve symbol
symbol : class ServletException
location: class HelloWorldBean
throws IOException, ServletException
^
6 errors
我用jdk1.3编译,出错! 是我环境没配好吗?
源代码如下:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldBean extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
}
}
following is the Error Info:
////////////////////////////////////////////////////////////
HelloWorldBean.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
HelloWorldBean.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HelloWorldBean.java:5: cannot resolve symbol
symbol : class HttpServlet
location: class HelloWorldBean
public class HelloWorldBean extends HttpServlet {
^
HelloWorldBean.java:7: cannot resolve symbol
symbol : class HttpServletRequest
location: class HelloWorldBean
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
HelloWorldBean.java:7: cannot resolve symbol
symbol : class HttpServletResponse
location: class HelloWorldBean
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
HelloWorldBean.java:8: cannot resolve symbol
symbol : class ServletException
location: class HelloWorldBean
throws IOException, ServletException
^
6 errors
|
将servlet.jar加入类路径下