Skip to content

Instantly share code, notes, and snippets.

@minikuma
Created January 10, 2019 06:35
Show Gist options
  • Save minikuma/c02e683d041df15e5981564c9c33ae11 to your computer and use it in GitHub Desktop.
Save minikuma/c02e683d041df15e5981564c9c33ae11 to your computer and use it in GitHub Desktop.
public class ExampleServlet extends HttpServlet {
//doPost 재 정의
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html; charset=UTF-8");
// Response 객체의 PrintWriter를 사용해 브라우저에 HTML을 출력한다.
PrintWriter out = resp.getWriter();
out.println("<HTML><HEAD><TITLE>HelloServlet</TITLE></HEAD>");
out.println("<BODY>");
out.println("<H2> Clinet IP: " + req.getRemoteAddr() + "</H2>");
out.println("<H2> Client Host : " + req.getRemoteHost() + "</H2>");
out.println("<H2> Request URI : " + req.getRequestURI() + "</H2>");
out.println("</BODY></HTML>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment