javaでServletインターフェイスを実現するプログラム

javaコード:

package com.startnews24Syn.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class HelloWorldServlet implements Servlet{

public void destroy() {
// TODO Auto-generated method stub
System.out.println(“destroy it");
}

public ServletConfig getServletConfig() {
// TODO Auto-generated method stub
return null;
}

public String getServletInfo() {
// TODO Auto-generated method stub
return null;
}

public void init(ServletConfig arg0) throws ServletException {
// TODO Auto-generated method stub
System.out.println(“init it");

}

public void service(ServletRequest request, ServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println(“service it");
PrintWriter printWriter=response.getWriter();
printWriter.println(“<h1>"+"hello,world"+"</h1>");
}

}

Java

Posted by arkgame