package com.hailuo.servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
public class Servlet01 extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
ServletConfig servletConfig = getServletConfig();
String webSite = servletConfig.getInitParameter("webSite");
String email = servletConfig.getInitParameter("email");
PrintWriter writer = response.getWriter();
writer.println("<h1>"+webSite+"</h1>");
writer.println("<h1>"+email+"</h1>");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
}
访问结果