본문 바로가기

java

java request information

<%--
 Author : francis lee
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="false"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="java.lang.reflect.Field"%>
<%@ page import="java.lang.reflect.Method"%>
<%@ page import="org.springframework.util.ReflectionUtils"%>

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>request information</title>
<link rel="stylesheet" href="">
<style type="text/css">
</style>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.7.2.min.js" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {

});
</script>
</head>
<body>
<div>
<h2>request</h2>
<table border="1" width="100%">
    <tr>
        <th width="30%">name</th>
        <th width="70%">value</th>
    </tr>
<%
Method[] methods = request.getClass().getDeclaredMethods();
//Method[] methods = ReflectionUtils.getAllDeclaredMethods(request.getClass());
//Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(request.getClass());
for (Method method : methods){
    if(method.getParameterTypes().length == 0 && (method.getReturnType().getSimpleName().equals("String") || method.getReturnType().getSimpleName().equals("boolean"))){
        Object object = ReflectionUtils.invokeMethod(method, request);
        out.print("<tr>");
        out.print("<td>" + method.getName() + "</td>");
        out.print("<td>" + object + "</td>");
        out.print("</tr>");
    }
}
%>
</table>

<h2>request header</h2>
<table border="1" width="100%">
    <tr>
        <th width="30%">name</th>
        <th width="70%">value</th>
    </tr>
<%
    Enumeration<String> headerNames = request.getHeaderNames();
    while (headerNames.hasMoreElements()) {
        String headerName = headerNames.nextElement();
        out.print("<tr>");
        out.print("<td>" + headerName + "</td>");
        out.print("<td>" + request.getHeader(headerName) + "</td>");
        out.print("</tr>");
    }
%>
</table>
</div>
</body>
</html>

'java' 카테고리의 다른 글

자바 가변인자 (variable argument type)  (0) 2010.05.10
구글날씨 api 이용하기  (5) 2009.01.23
Tag Library Function  (0) 2009.01.19
Custom Tags in JSP Pages  (0) 2008.12.31
Java -classpath 옵션  (1) 2008.04.29