helloservlet

package main;

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

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class F1 extends HttpServlet {



public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("处理get请求。。。");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println(" A Servlet");
out.println(" ");
out.println("hello servlet");
out.println(" ");
out.println("");
out.flush();
out.close();

}


public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("处理post请求。。。");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println(" A Servlet");
out.println(" ");
out.println("hello servlet");
out.println(" ");
out.println("");
out.flush();
out.close();
}

 

}

转载于:https://www.cnblogs.com/lingasher/p/6636423.html

你可能感兴趣的:(java)