本文发表在 rolia.net 枫下论坛I test a Servlet program to know more about the class GenericServlet .But I met some errors. Why?
The program is HelloWorldSerlet.java:
import java.io.*;
import java.util.Date;
import javax.Servlet.*;
public class HelloWorldServlet extends GenericServlet
{
String initString;
public void init(ServletConfig config)
throw ServletException
{
super.init(config);
initString=new String("I have been initialized");
}
public void Service(ServletRequest req,ServletRespone res)
{
Date today=new Date();
ServletOutputStream out=res.getOutputStream();
out.println("Hello World");
out.println(today.toString());
out.println(getServletInfo());
}
public void Destroy()
{
}
pubic String getServletInfo()
{
return "Create a page that says Hello World and send date back produced by djf";
}
}
And I already to set the path=c:\jdk1.1.8\bin;
CLASSPATH=c:\jdk1.1.8\class\classes.zip
And I used "javac HelloWorldServlet.java" to compile it,but I got errors:
"Package javax.Servlet not found in import."
"Superclass GenericServlet of class HelloWorldServlet not found..."
I check my path and classpath for many times, I have no idea ! :-(
Help me!更多精彩文章及讨论,请光临枫下论坛 rolia.net
The program is HelloWorldSerlet.java:
import java.io.*;
import java.util.Date;
import javax.Servlet.*;
public class HelloWorldServlet extends GenericServlet
{
String initString;
public void init(ServletConfig config)
throw ServletException
{
super.init(config);
initString=new String("I have been initialized");
}
public void Service(ServletRequest req,ServletRespone res)
{
Date today=new Date();
ServletOutputStream out=res.getOutputStream();
out.println("Hello World");
out.println(today.toString());
out.println(getServletInfo());
}
public void Destroy()
{
}
pubic String getServletInfo()
{
return "Create a page that says Hello World and send date back produced by djf";
}
}
And I already to set the path=c:\jdk1.1.8\bin;
CLASSPATH=c:\jdk1.1.8\class\classes.zip
And I used "javac HelloWorldServlet.java" to compile it,but I got errors:
"Package javax.Servlet not found in import."
"Superclass GenericServlet of class HelloWorldServlet not found..."
I check my path and classpath for many times, I have no idea ! :-(
Help me!更多精彩文章及讨论,请光临枫下论坛 rolia.net