<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.util.Enumeration" %>
<%@ page session="true" %>
<%
	String url = javax.servlet.http.HttpUtils.getRequestURL(request).toString();

	String scheme = request.getHeader("X-Forwarded-Proto");
	if (scheme == null || scheme.length() == 0 || "unknown".equalsIgnoreCase(scheme)) {
		scheme = request.getHeader("x-forwarded-proto");
	}
	if (scheme == null || scheme.length() == 0 || "unknown".equalsIgnoreCase(scheme)) {
		scheme = request.getScheme();
	}
	String[] schemes = scheme.split(",");
	scheme = schemes[0];

	String ip = request.getHeader("X-Forwarded-For");
	if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
		ip = request.getHeader("Proxy-Client-IP");
	}
	if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
		ip = request.getHeader("WL-Proxy-Client-IP");
	}
	if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
		ip = request.getHeader("HTTP_CLIENT_IP");
	}
	if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
		ip = request.getHeader("HTTP_X_FORWARDED_FOR");
	}
	if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
		ip = request.getRemoteAddr();
	}
	String[] ips = ip.split(",");
	ip = ips[0];
%>
<html lang="ko">
<head>
	<title> WEB</title>
</head>

<body>
	<h1>STYLE24 WEB!! (<%=url %>) </h1>

	<a href="monitoring.jsp">MONITORING</a>
	<a href="/">INDEX</a>

	<p>request.getProtocol() : <%=request.getProtocol() %></p>
	<p>StringUtil.getRemoteAddr(request) : <%=scheme %></p>
	<p>request.getRemoteAddr() : <%=request.getRemoteAddr() %></p>

	<p>StringUtil.getScheme(request) : <%=scheme %></p>
	<p>request.getScheme() : <%=request.getScheme() %></p>

	<p>request.getHeader("REFERER") : <%=request.getHeader("REFERER") %></p>

	<p>request.getServerName() : <%=request.getServerName() %></p>
	<p>request.getServerPort() : <%=request.getServerPort() %></p>
	<p>request.getLocalName() : <%=request.getLocalName() %></p>
	<p>request.getLocalPort() : <%=request.getLocalPort() %></p>
	<p>java.library.path : <%=System.getProperty("java.library.path") %></p>

	<hr>
	<h3>session</h3>
	<p>ID : <%=session.getId()%></p>
	<%
		Enumeration sessions = session.getAttributeNames();
		while(sessions.hasMoreElements()){
			String attributeName = sessions.nextElement().toString();
			String attributeValue = session.getAttribute(attributeName).toString();
	%>
	<p><%=attributeName%> : <%=attributeValue%></p>
	<%
		}
	%>

	<hr>
	<h3>request.getHeaders</h3>
	<%
		Enumeration headers = request.getHeaderNames();
		while(headers.hasMoreElements()){
			String headerName = headers.nextElement().toString();
			String headerValue = request.getHeader(headerName);
	%>
	<p><%=headerName%> : <%=headerValue%></p>
	<%
		}
	%>

	<hr>
	<h3>request.getAttribute</h3>
	<%
		Enumeration attributes = request.getAttributeNames();
		while(attributes.hasMoreElements()){
			String attributeName = attributes.nextElement().toString();
			String attributeValue = request.getAttribute(attributeName).toString();
	%>
	<p><%=attributeName%> : <%=attributeValue%></p>
	<%
		}
	%>
</body>
</html>
