Java

URI, URL, ContentPath, RemoteAddr 출력

dhl7799 2024. 2. 22. 13:14
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>");
}

 

URI : /firstweb/Info
URL : http://localhost:8080/firstweb/Info
ContentPath : /firstweb
RemoteAddr : 0:0:0:0:0:0:0:1