클라우드가 요청을 하면 was는 HttpServletRequest와 HttpServletResponse를 생성한다
was는 서블릿에게 이것을 전달
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>form</title></head>");
out.println("<body>");
Enumeration<String> headerNames = request.getHeaderNames();
while(headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
String headerValue = request.getHeader(headerName);
out.println(headerName + " : " + headerValue + " <br> ");
}
out.println("</body>");
out.println("</html>");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>form</title></head>");
out.println("<body>");
String name = request.getParameter("name");
String age = request.getParameter("age");
out.println("name : " + name + "<br>");
out.println("age : " +age + "<br>");
out.println("</body>");
out.println("</html>");
}
name : null
age : null
서블릿주소?name=kim&age=5
로 입력해주어야 name과 age의 값을 입력받아 실행할수있다.name : kim
age : 5
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>info</title></head>");
out.println("<body>");
String uri = request.getRequestURI();
StringBuffer url = request.getRequestURL();
String contentPath = request.getContextPath();
String remoteAddr = request.getRemoteAddr();
out.println("uri : " + uri + "<br>");
out.println("url : " + url + "<br>");
out.println("contentPath : " + contentPath + "<br>");
out.println("remoteAddr : " + remoteAddr + "<br>");
out.println("</body>");
out.println("</html>");
}
String uri = request.getRequestURI();
StringBuffer url = request.getRequestURL();
String contentPath = request.getContextPath();
String remoteAddr = request.getRemoteAddr();
uri : /exam31/info
url : http://localhost:8888/exam31/info
contentPath : /exam31
remoteAddr : 0:0:0:0:0:0:0:1