因为是通过HTTPS协议进行访问的,所以只能实现HttpServlet中的service方法,程序如下:
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class StubServ100 extends HttpServlet{
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
String xmldata = "TESTSSL";
response.setContentType("text/xml;charset=utf-8");
response.setContentLength(request.getContentLength());
// レスポンスの出力
PrintWriter out = response.getWriter();
out.println(xmldata);
} catch (Exception e) {
e.printStackTrace();
}
}
}