반응형
http://localhost:8080/firstweb/info
InfoServlet.java
only doGet() Method
@Override
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(); // domain, port num 이후 정보
StringBuffer url = request.getRequestURL();
String contentPath = request.getContextPath(); // WAS에는 여러웹앱이 존재할 수 있는데 특정 웹앱을 찾아가는 root이름
String remoteAddr = request.getRemoteAddr(); // cli의 주소값
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>");
}
반응형