本文发表在 rolia.net 枫下论坛I create a servlet program named
HelloWorldServlet.java
import java.io.*;
import java.util.Date;
import javax.servlet.*;
public class HelloWorldServlet extends GenericServlet
{
String initString;
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
initString=new String("I have been initialized");
}
public void Service(ServletRequest req,ServletResponse res)
throws IOException, ServletException
{
Date today=new Date();
ServletOutputStream out=res.getOutputStream();
out.println("Hello World");
out.println(today.toString());
out.println(getServletInfo());
}
public void Destroy()
{
}
public String getServletInfo()
{
return "Create a page that says Hello World and send date back produced by djf";
}
}
When I compile it ,it shows me "Class HelloWorldSerlet must be declared abstrat.It dose not define void service...."
It seems that I didn't success declare the class HelloWorldServlet at first.
I just want to test the method of GenericServlet.
So please tell why I got that error.更多精彩文章及讨论,请光临枫下论坛 rolia.net
HelloWorldServlet.java
import java.io.*;
import java.util.Date;
import javax.servlet.*;
public class HelloWorldServlet extends GenericServlet
{
String initString;
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
initString=new String("I have been initialized");
}
public void Service(ServletRequest req,ServletResponse res)
throws IOException, ServletException
{
Date today=new Date();
ServletOutputStream out=res.getOutputStream();
out.println("Hello World");
out.println(today.toString());
out.println(getServletInfo());
}
public void Destroy()
{
}
public String getServletInfo()
{
return "Create a page that says Hello World and send date back produced by djf";
}
}
When I compile it ,it shows me "Class HelloWorldSerlet must be declared abstrat.It dose not define void service...."
It seems that I didn't success declare the class HelloWorldServlet at first.
I just want to test the method of GenericServlet.
So please tell why I got that error.更多精彩文章及讨论,请光临枫下论坛 rolia.net