当前位置: 技术问答>java相关
请问各位,我这个servlet为什么不能编译通过?
来源: 互联网 发布时间:2015-10-04
本文导语: 安装jdk1.3,设置好了path和classpath,其它java程序编译通过。下载了servlet.jar,拷贝到d:jdk1.3lib目录,然后编译下面这段servelet程序,提示找不到包,然后我去掉第3行和第4行的"javax.",然后编译同样的错误: import java.util.*; ...
安装jdk1.3,设置好了path和classpath,其它java程序编译通过。下载了servlet.jar,拷贝到d:jdk1.3lib目录,然后编译下面这段servelet程序,提示找不到包,然后我去掉第3行和第4行的"javax.",然后编译同样的错误:
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ExampleServlet extends HttpServlet {
public void doGet (HttpServletRequest request, HttpServletResponse
response) throws IOException
{
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("Headers sent with the request:
");
for (Enumeration headers = request.getHeaderNames();
headers.hasMoreElements();)
{
String headerName = (String) headers.nextElement();
out.println("
" + headerName + ": " +
request.getHeader(headerName));
}
} // end of method
} // end of class
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ExampleServlet extends HttpServlet {
public void doGet (HttpServletRequest request, HttpServletResponse
response) throws IOException
{
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("Headers sent with the request:
");
for (Enumeration headers = request.getHeaderNames();
headers.hasMoreElements();)
{
String headerName = (String) headers.nextElement();
out.println("
" + headerName + ": " +
request.getHeader(headerName));
}
} // end of method
} // end of class
|
你试试把servlet.jar加到环境变量里边去,看能不能行!!
|
你试试把servlet.jar加到环境变量里边去,一定行
|
在你的classpath中,加上servlet的路径servlet.jar这句,就可以了