Hi, I want code and the details of Snoop in JSP, can anyone help me to get this? I am waiting for your reply. Please, help me in this to get information. I am waiting for your reply.
Hi, I want code and the details of Snoop in JSP, can anyone help me to get this? I am waiting for your reply. Please, help me in this to get information. I am waiting for your reply.
Hi, The snoop in Jsp is many times contains the request information, ServletContext initialization parameters, ServetContext attributes, request headers, response headers etc. etc.
You can use the following code to get information about the Snoop:
Code:<%@ page import="javax.servlet.http.HttpUtils,java.util.*" %> <h2> Request Information </h2> JSP Request Method: <%= request.getMethod() %><br> Request URI: <%= request.getRequestURI() %><br> Request Protocol: <%= request.getProtocol() %><br> Servlet path: <%= request.getServletPath() %><br> Path info: <%= request.getPathInfo() %><br> Query string: <%= request.getQueryString() %><br> Content length: <%= request.getContentLength() %><br> Content type: <%= request.getContentType() %><br> Server name: <%= request.getServerName() %><br> Server port: <%= request.getServerPort() %><br> Remote user: <%= request.getRemoteUser() %><br> Remote address: <%= request.getRemoteAddr() %><br> Remote host: <%= request.getRemoteHost() %><br> Authorization scheme: <%= request.getAuthType() %> <br> Locale: <%= request.getLocale() %> <hr>The browser you are using is <%= request.getHeader("User-Agent") %><hr> </body> </html>
Hi, I don't know have more knowledge about the JSP. But, I don't know what is snoop. But, I have got the code which will help you to get some knowledge about snoop. Use the code below.
Code:<HTML> <HEAD> <TITLE>JSP snoop page</TITLE> <%@ page import="javax.servlet.http.HttpUtils,java.util.Enumeration" %> </HEAD> <BODY> <H1>Code for JSP Snoop</H1> <TABLE> <TR> <TH align=right>Server Info:</TH> <TD><%= application.getServerInfo() %></TD> </TR> </TABLE> <H2>Request information</H2> <TABLE> <TR> <TH align=right>Requested URL:</TH> <TD><%= HttpUtils.getRequestURL(request) %></TD> </TR> <TR> <TH align=right>Request method:</TH> <TD><%= request.getMethod() %></TD> </TR> <TR> <TH align=right>Request URI:</TH> <TD><%= request.getRequestURI() %></TD> </TR> <TR> <TH align=right>Request protocol:</TH> <TD><%= request.getProtocol() %></TD> </TR> <TR> <TH align=right>Servlet path:</TH> <TD><%= request.getServletPath() %></TD> </TR> <TR> <TH align=right>Path info:</TH> <TD><%= request.getPathInfo() %></TD> </TR> <TR> <TH align=right>Path translated:</TH> <TD><%= request.getPathTranslated() %></TD> </TR> <TR> <TH align=right>Query string:</TH> <TD><%= request.getQueryString() %></TD> </TR> <TR> <TH align=right>Content length:</TH> <TD><%= request.getContentLength() %></TD> </TR> <TR> <TH align=right>Content type:</TH> <TD><%= request.getContentType() %></TD> <TR> <TR> <TH align=right>Server name:</TH> <TD><%= request.getServerName() %></TD> <TR> <TR> <TH align=right>Server port:</TH> <TD><%= request.getServerPort() %></TD> <TR> <TR> <TH align=right>Remote user:</TH> <TD><%= request.getRemoteUser() %></TD> <TR> <TR> <TH align=right>Remote address:</TH> <TD><%= request.getRemoteAddr() %></TD> <TR> <TR> <TH align=right>Remote host:</TH> <TD><%= request.getRemoteHost() %></TD> <TR> <TR> <TH align=right>Authorization scheme:</TH> <TD><%= request.getAuthType() %></TD> <TR> </TABLE> <% Enumeration enum = request.getHeaderNames(); if(enum != null && enum.hasMoreElements()) { %> <H2>Request headers</H2> <TABLE> <TR> <TH align=left>Header:</TH> <TH align=left>Value:</TH> </TR> <% while(enum.hasMoreElements()) { String str = (String) enum.nextElement(); %> <TR> <TD><%= str %></TD> <TD><%= request.getHeader(str) %></TD> </TR> <% } %> </TABLE> <% } %> <% enum = request.getParameterNames(); if(enum != null && enum.hasMoreElements()) { %> <H2>Request parameters</H2> <TABLE> <TR valign=top> <TH align=left>Parameter:</TH> <TH align=left>Value:</TH> <TH align=left>Multiple values:</TH> </TR> <% while(enum.hasMoreElements()) { String str = (String) enum.nextElement(); String value = request.getParameter(str); String values[] = request.getParameterValues(str); %> <TR valign=top> <TD><%= str %></TD> <TD><%= value %></TD> <TD><% for(int i = 0; i < values.length; i++) { if(i > 0) out.print("<BR>"); out.print(values[i]); } %></TD> </TR> <% } %> </TABLE> <% } %> <% enum = getServletConfig().getInitParameterNames(); if(enum != null && enum.hasMoreElements()) { %> <H2>Init parameters</H2> <TABLE> <TR valign=top> <TH align=left>Parameter:</TH> <TH align=left>Value:</TH> </TR> <% while(enum.hasMoreElements()) { String str = (String) enum.nextElement(); String value = getServletConfig().getInitParameter(str); %> <TR valign=top> <TD><%= str %></TD> <TD><%= value %></TD> </TR> <% } %> </TABLE> <% String prefix = "org.apache.jserv."; Object attrsObj = request.getAttribute("org.apache.jserv.attribute_names"); if ( attrsObj != null && attrsObj instanceof Enumeration ) { Enumeration attrs = (Enumeration) attrsObj; %> <P> <H1>JServ Attributes</H1> available via HttpServletRequest.getAttribute() <BR> <TABLE> <% while ( attrs.hasMoreElements()) { String attr = attrs.nextElement().toString(); %> <TR><TD> <% if ( request.getAttribute(prefix + attr) != null ) { out.println( prefix + attr + "</TD><TD>" + request.getAttribute(prefix + attr).toString()); } else { out.println( prefix + attr + "</TD><TD>NULL " ); } %> </TD></TR> <% } } %> </TABLE> <% } %> </BODY> </HTML>
Hi, I am not having any information about the snoop in JSP, but I am very keen to get information about the Snoop from JSP. I have searched on internet, but unable to get information about this. If you got more about this, then give it to me also. I am waiting for reply. I also want to gain some more information about this, so please give me if you have any information.
Bookmarks