即使在设置类路径后,包javax.servlet也不存在 [英] package javax.servlet does not exist even after setting the class path
本文介绍了即使在设置类路径后,包javax.servlet也不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码......一个基本的servlet代码。
Here's My code... a basic servlet code.
//Servlet (interface)
import javax.servlet.*;
import java.io.*;
public class DemoServlet1 implements Servlet
{
public void init(ServletConfig config)
{ }
public void service (ServletRequest req, ServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<html><body>");
out.println("WELCOME SERVLET");
out.println("</body></html>");
}
public void destroy()
{}
public ServletConfig getServletConfig()
{
return null;
}
public String getServletInfo()
{
return null;
}
}
编译它....它会抛出javax.servlet不存在。
类路径和路径是正确的,因为我ctrl c + ctrl ved !!!!
并且它在其他机器上运行,而它在我的机器中显示以下错误响应。
我使用的是Win 7(64位)......我猜不是必需的!
COMPILING it.... it throws javax.servlet does not exist.
The classpath and path are correct as I "ctrl c + ctrl v"ed it!!!
and its running on other machines, while its showing the following error response in mine.
I am using Win 7 (64bit)... not necessary i guess!!
G:\2>set path = C:\beaB\jdk141_02\bin
G:\2>set classpath = %classpath%;C:\beaB\weblogic81\server\lib\weblogic.jar
G:2>javac DemoServlet1.java
DemoServlet1.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
DemoServlet1.java:4: cannot find symbol
symbol: class Servlet
public class DemoServlet1 implements Servlet
^
DemoServlet1.java:6: cannot find symbol
symbol : class ServletConfig
location: class DemoServlet1
public void init(ServletConfig config)
^
DemoServlet1.java:8: cannot find symbol
symbol : class ServletRequest
location: class DemoServlet1
public void service (ServletRequest req, ServletResponse res)
throws ServletException, IOException
DemoServlet1.java:8: cannot find symbol
symbol : class ServletResponse
location: class DemoServlet1
public void service (ServletRequest req, ServletResponse res)throws ServletExcep
tion, IOException
^
DemoServlet1.java:8: cannot find symbol
symbol : class ServletException
location: class DemoServlet1
public void service (ServletRequest req, ServletResponse res)throws ServletExcep
tion, IOException
^
DemoServlet1.java:18: cannot find symbol
symbol : class ServletConfig
location: class DemoServlet1
public ServletConfig getServletConfig()
^
7 errors
我该怎么办?
推荐答案
你应该<类路径中的code> servlet-api.jar 。它应该出现在 weblogic81 \ server \lib \
目录中。
You should have servlet-api.jar
in the classpath. It should be present in weblogic81\server\lib\
directory.
这篇关于即使在设置类路径后,包javax.servlet也不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文