import java.io.*;
import java.util.*;
//导入servlet包
import javax.servlet.*;
public class HelloServlet extends GenericServlet
{
public void init(ServletConfig config)throws ServletException
{
super.init(config);
//调用父类的初始化方法;也可以加入自己需要的初始化代码。
}
public void destroy(){
//destroy方法中加入一些做最后清理工作的代码;
}
public String getServletInfo(){
return "This servlet is a simple Servlet's example.";
//返回此servlet的信息 ;
}
public void service(ServletRequest req,ServletResponse res)
throws ServletException,IOException
{ //service是最主要的方法,提供服务
//获得服务器当前时间。
Date today=new Date(); //获得响应用户请求的输出流,以反馈执行结果;
ServletOutputStream out=res.getOutputStream(); //通过输出流向客户端写回了一个HTML文件;
out.println("<html><head><title>HelloServlet.java</title></head><body>");
out.println("Hello,this is my first test.+<BR>");
out.println("Today is "+today.toString()+"<BR>");
out.println(getServletInfo()+"<BR>");
}
}我就按了JDK 是不是要安J2EE??
import java.util.*;
//导入servlet包
import javax.servlet.*;
public class HelloServlet extends GenericServlet
{
public void init(ServletConfig config)throws ServletException
{
super.init(config);
//调用父类的初始化方法;也可以加入自己需要的初始化代码。
}
public void destroy(){
//destroy方法中加入一些做最后清理工作的代码;
}
public String getServletInfo(){
return "This servlet is a simple Servlet's example.";
//返回此servlet的信息 ;
}
public void service(ServletRequest req,ServletResponse res)
throws ServletException,IOException
{ //service是最主要的方法,提供服务
//获得服务器当前时间。
Date today=new Date(); //获得响应用户请求的输出流,以反馈执行结果;
ServletOutputStream out=res.getOutputStream(); //通过输出流向客户端写回了一个HTML文件;
out.println("<html><head><title>HelloServlet.java</title></head><body>");
out.println("Hello,this is my first test.+<BR>");
out.println("Today is "+today.toString()+"<BR>");
out.println(getServletInfo()+"<BR>");
}
}我就按了JDK 是不是要安J2EE??
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货