我在cmd上编译时遇到了这个servlet程序的问题,我在cmd上设置了weblogic.jar文件的类路径 - set classpath=C:\Oracle\Middleware\wlserver_12.1\server\lib\weblogic.jar;
我的代码是 -
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class DemoServlet1 implements Servlet
{
public void init(ServletConfig con)
{}
public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<html><body>");
out.println("hello servlet !!!!");
out.println("</body></html>");
}
public void destroy()
{}
public ServletConfig getServletConfig()
{
return null;
}
public String getServletInfo()
{
return null;
}
}
错误讯息 -
C:\javaharsh\Demo>set class path=C:\Oracle\Middleware\wlserver_12.1\server\lib\w
eblogic.jar;
C:\javaharsh\Demo>javac DemoServlet1.java
DemoServlet1.java:1: error: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
DemoServlet1.java:2: error: package javax.servlet does not exist
import javax.servlet.*;
^
DemoServlet1.java:4: error: cannot find symbol
public class DemoServlet1 implements Servlet
^
symbol: class Servlet
DemoServlet1.java:6: error: cannot find symbol
public void init(ServletConfig con)
^
symbol: class ServletConfig
location: class DemoServlet1
DemoServlet1.java:8: error: cannot find symbol
public void service(ServletRequest req,ServletResponse res)throws Servle
tException,IOException
^
symbol: class ServletRequest
location: class DemoServlet1
DemoServlet1.java:8: error: cannot find symbol
public void service(ServletRequest req,ServletResponse res)throws Servle
tException,IOException
^
symbol: class ServletResponse
location: class DemoServlet1
DemoServlet1.java:8: error: cannot find symbol
public void service(ServletRequest req,ServletResponse res)throws Servle
tException,IOException
^
symbol: class ServletException
location: class DemoServlet1
DemoServlet1.java:18: error: cannot find symbol
public ServletConfig getServletConfig()
^
symbol: class ServletConfig
location: class DemoServlet1
8 errors