用于查看请求和响应以及会话内容的 JSP 代码

发布于 2024-10-06 08:37:32 字数 189 浏览 3 评论 0原文

我正在尝试调试 HTTP 会话被删除或浏览器未发回 cookie 的问题。由于我们必须处理的安全限制,我需要一个可以放在服务器上的 JSP,该 JSP 将显示请求的内容、响应和 HTTP 会话的内容。

有人有可以执行此操作的代码吗?它应该是一个独立的 JSP,我可以将其放入现有的 WAR 文件中(因此假设我只能访问默认的 Sun java 库)。

I am trying to debug an issue where either the HTTP Session is being dropped or the cookie is not being sent back by the browser. Due to the security contstraints that we have to deal with, I am left with needing a JSP That I can drop on the server that will display the contents of the Request, the Response, and the contents of the HTTP Session.

Does anyone have any code that will do this? It should be a self-contained JSP that I can drop into an existing WAR file (so assume I only have access to the default Sun java libraries).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泅人 2024-10-13 08:37:32

将以下内容放入 jsp 文件中,您将获得所需的所有信息

<%

out.println("<h1>application scope</h1>");
java.util.Enumeration e=application.getAttributeNames();
out.println("<table border='3' width='1000px'>");
while(e.hasMoreElements())
    {
        String name=(String)e.nextElement();

        Object value=application.getAttribute(name);
        if(value==null)
        {
        value="NONE";
        }
        System.out.println(name+":"+value);
        if(!name.contains("ibm") && !name.contains("myfaces")       )
        {
            if(value!=null && value.getClass().toString().contains("versata"))
            {
                out.println("<tr style='font-weight:bold;color:red;'>");        
            }
            else
            {
                out.println("<tr>");    
            }
                out.println("<td>");        
                out.println("Name: "+name);
                out.println("</td>");       
                out.println("<td>");        
                out.println("Value: "+value);
                out.println("</td>");       
                if(value!=null)
                {
                out.println("<td>");        
                out.println("Class: "+value.getClass());
                out.println("</td>");       
                }
                out.println("</tr>");       
        }
    }
out.println("</table>");
out.println("<h1>session scope</h1>");

e=session.getAttributeNames();
out.println("<table border='3' width='1000px'>");
while(e.hasMoreElements())
    {
        String name=(String)e.nextElement();

        Object value=application.getAttribute(name);
        if(value==null)
        {
        value="NONE";
        }
        System.out.println(name+":"+value);
        if(!name.contains("ibm") && !name.contains("myfaces")       )
        {
            if(value!=null && value.getClass().toString().contains("versata"))
            {
                out.println("<tr style='font-weight:bold;color:red;'>");        
            }
            else
            {
                out.println("<tr>");    
            }
                out.println("<td>");        
                out.println("Name: "+name);
                out.println("</td>");       
                out.println("<td>");        
                out.println("Value: "+value);
                out.println("</td>");       
                if(value!=null)
                {
                out.println("<td>");        
                out.println("Class: "+value.getClass());
                out.println("</td>");       
                }
                out.println("</tr>");       
        }
    }
out.println("</table>");

out.println("<h1>request scope</h1>");

e=request.getAttributeNames();
out.println("<table border='3' width='1000px'>");
while(e.hasMoreElements())
    {
        String name=(String)e.nextElement();

        Object value=application.getAttribute(name);
        if(value==null)
        {
        value="NONE";
        }
        System.out.println(name+":"+value);
        if(!name.contains("ibm") && !name.contains("myfaces")       )
        {
            if(value!=null && value.getClass().toString().contains("versata"))
            {
                out.println("<tr style='font-weight:bold;color:red;'>");        
            }
            else
            {
                out.println("<tr>");    
            }
                out.println("<td>");        
                out.println("Name: "+name);
                out.println("</td>");       
                out.println("<td>");        
                out.println("Value: "+value);
                out.println("</td>");       
                if(value!=null)
                {
                out.println("<td>");        
                out.println("Class: "+value.getClass());
                out.println("</td>");       
                }
                out.println("</tr>");       
        }
    }
out.println("</table>");

%>

Put the below in a jsp file and and you will get all the info you asked for

<%

out.println("<h1>application scope</h1>");
java.util.Enumeration e=application.getAttributeNames();
out.println("<table border='3' width='1000px'>");
while(e.hasMoreElements())
    {
        String name=(String)e.nextElement();

        Object value=application.getAttribute(name);
        if(value==null)
        {
        value="NONE";
        }
        System.out.println(name+":"+value);
        if(!name.contains("ibm") && !name.contains("myfaces")       )
        {
            if(value!=null && value.getClass().toString().contains("versata"))
            {
                out.println("<tr style='font-weight:bold;color:red;'>");        
            }
            else
            {
                out.println("<tr>");    
            }
                out.println("<td>");        
                out.println("Name: "+name);
                out.println("</td>");       
                out.println("<td>");        
                out.println("Value: "+value);
                out.println("</td>");       
                if(value!=null)
                {
                out.println("<td>");        
                out.println("Class: "+value.getClass());
                out.println("</td>");       
                }
                out.println("</tr>");       
        }
    }
out.println("</table>");
out.println("<h1>session scope</h1>");

e=session.getAttributeNames();
out.println("<table border='3' width='1000px'>");
while(e.hasMoreElements())
    {
        String name=(String)e.nextElement();

        Object value=application.getAttribute(name);
        if(value==null)
        {
        value="NONE";
        }
        System.out.println(name+":"+value);
        if(!name.contains("ibm") && !name.contains("myfaces")       )
        {
            if(value!=null && value.getClass().toString().contains("versata"))
            {
                out.println("<tr style='font-weight:bold;color:red;'>");        
            }
            else
            {
                out.println("<tr>");    
            }
                out.println("<td>");        
                out.println("Name: "+name);
                out.println("</td>");       
                out.println("<td>");        
                out.println("Value: "+value);
                out.println("</td>");       
                if(value!=null)
                {
                out.println("<td>");        
                out.println("Class: "+value.getClass());
                out.println("</td>");       
                }
                out.println("</tr>");       
        }
    }
out.println("</table>");

out.println("<h1>request scope</h1>");

e=request.getAttributeNames();
out.println("<table border='3' width='1000px'>");
while(e.hasMoreElements())
    {
        String name=(String)e.nextElement();

        Object value=application.getAttribute(name);
        if(value==null)
        {
        value="NONE";
        }
        System.out.println(name+":"+value);
        if(!name.contains("ibm") && !name.contains("myfaces")       )
        {
            if(value!=null && value.getClass().toString().contains("versata"))
            {
                out.println("<tr style='font-weight:bold;color:red;'>");        
            }
            else
            {
                out.println("<tr>");    
            }
                out.println("<td>");        
                out.println("Name: "+name);
                out.println("</td>");       
                out.println("<td>");        
                out.println("Value: "+value);
                out.println("</td>");       
                if(value!=null)
                {
                out.println("<td>");        
                out.println("Class: "+value.getClass());
                out.println("</td>");       
                }
                out.println("</tr>");       
        }
    }
out.println("</table>");

%>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文