浏览 3188 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2006-12-21
1.测试类
我写了一个RequestInfoServlet,可以显示HttpRequest的绝大部分有用信息,经过sso后,可以查看 HttpRequest里面还有什么东西。呵呵,我喜欢这样干。 import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import javax.servlet.ServletException; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * @author Liujj Date 2006-12-19 <br> * Description: <br> * RequestHeadersServlet */ public class RequestInfoServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); //header Enumeration headerNames = request.getHeaderNames(); out.println("<B>*********[1].begin print headerNames************</B><p>"); while (headerNames.hasMoreElements()) { String name = (String) headerNames.nextElement(); String value = request.getHeader(name); out.println(name + " = " + value + "<p>"); } out.println("<B>*********[1].end print headerNames************</B><p><p>"); //attributeNames out.println("<B>*********[2].begin print attributeNames************</B><p>"); Enumeration attributeNames = request.getAttributeNames(); while (attributeNames.hasMoreElements()) { String name = (String) attributeNames.nextElement(); String value = (String)request.getAttribute(name); out.println(name + " = " + value + "<p>"); } out.println("<B>*********[2].end print attributeNames************</B><p><p>"); //parameterNames out.println("<B>*********[3].begin print parameterNames************</B><p>"); Enumeration parameterNames = request.getParameterNames(); while (parameterNames.hasMoreElements()) { String name = (String) parameterNames.nextElement(); String value = request.getParameter(name); out.println(name + " = " + value + "<p>"); } out.println("<B>*********[3].end print parameterNames************</B><p><p>"); //session out.println("<B>*********[4].begin print session AttributeNames************</B><p>"); HttpSession session = request.getSession(); Enumeration sAttributeNames = session.getAttributeNames(); while (sAttributeNames.hasMoreElements()) { String name = (String) sAttributeNames.nextElement(); Object value = session.getAttribute(name); out.println(name + " = " + value + "<p>"); } out.println("<B>*********[4].end print session attributeNames************</B><p><p>"); //cookie out.println("<B>*********[4].begin print Cookie************</B><p><p>"); Cookie[] cookie = request.getCookies(); for(int i=0; i< cookie.length; i++) { String name = cookie[i].getName(); String value = cookie[i].getValue(); out.println(name + " = " + value + "<p>"); } out.println("<B>*********[4].end print Cookie************</B><p><p>"); } } 2.cas log不起作用 目前那个log4j不起作用,天天用着的,算是个小bug,哪个兄弟下载后能帮忙解决一下,再次谢过^_^ 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2006-12-21
你的四个帖子可以分两个帖子已经够用了,这样让别人没有耐心看下去的
要别人1,2,3,4排下来看 有点像写代码时的code smells的感觉啊... |
|
返回顶楼 | |