jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eduardo Pelegri--Llopart <Eduardo.Pelegrillop...@eng.sun.com>
Subject Re: Offer to submit <form>-related taglib
Date Tue, 22 Aug 2000 14:13:47 GMT
Any chances of adding this to taglibs for general usage?  It seems a
good match.

	- eduard/o


sergek@lokitech.com wrote:
> 
> > From: Marco.Mistroni@nokia.com
> > Date: Tue Aug 22 08:25:45 EDT 2000
> >
> > hi Serge,
> >       can u give me a clue about how u did it?
> > thanx in advance & regards
> >       marco
> 
> I'd attach it, but I don't think the list allows it.
> 
> Serge Knystautas
> Loki Technologies
> http://www.lokitech.com/
> 
> --com.lokitech.taglib.SnoopTag.java---------------------
> package com.lokitech.taglib;
> 
> import java.io.*;
> import java.text.*;
> import java.util.*;
> 
> import javax.servlet.http.*;
> import javax.servlet.jsp.*;
> import javax.servlet.jsp.tagext.*;
> 
> /**
>  * Dumps all information available in the request object and from the
>  * servlet API
>  *
>  * Copyright 2000 Loki Technologies
>  *
>  * Sample usage:
>  *  <loki:snoop />
>  */
> 
> public class SnoopTag implements BodyTag {
>     public int doStartTag() throws JspException {
>         return SKIP_BODY;
>     }
> 
>     public void doInitBody() {
>     }
> 
>     public int doAfterBody() throws JspException {
>         return SKIP_BODY;
>     }
> 
>     public int doEndTag() throws JspException {
>         JspWriter out = pageContext.getOut();
>         HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
>         try {
>             out.println("<table border=\"1\">");
>             out.println("<tr><th colspan=\"3\">Server Information</th></tr>");
>             out.println("<tr><th>Current time</th><td>" + new
java.util.Date() + "</td><td>new java.util.Date()</td></tr>");
>             out.println("<tr><th>Locale</th><td>" + java.util.Locale.getDefault()
+ "</td><td>java.util.Locale.getDefault()</td></tr>");
>             out.println("<tr><th colspan=\"3\">Request Information</th></tr>");
>             out.println("<tr><th>Requested URL</th><td>" + HttpUtils.getRequestURL(request)
+ "</td><td>HttpUtils.getRequestURL(request)</td></tr>");
>             out.println("<tr><th>Request method</th><td>" + request.getMethod()
+ "</td><td>request.getMethod()</td></tr>");
>             out.println("<tr><th>Request URI</th><td>" + request.getRequestURI()
+ "</td><td>request.getRequestURI()</td></tr>");
>             out.println("<tr><th>Request protocol</th><td>" +
request.getProtocol() + "</td><td>request.getProtocol()</td></tr>");
>             out.println("<tr><th>Servlet path</th><td>" + request.getServletPath()
+ "</td><td>request.getServletPath()</td></tr>");
>             out.println("<tr><th>Path info</th><td>" + request.getPathInfo()
+ "</td><td>request.getPathInfo()</td></tr>");
>             out.println("<tr><th>Path translated</th><td>" +
request.getPathTranslated() + "</td><td>request.getPathTranslated()</td></tr>");
>             out.println("<tr><th>Query string</th><td>" + request.getQueryString()
+ "</td><td>request.getQueryString()</td></tr>");
>             out.println("<tr><th>Content length</th><td>" + request.getContentLength()
+ "</td><td>request.getContentLength()</td></tr>");
>             out.println("<tr><th>Content type</th><td>" + request.getContentType()
+ "</td><td>request.getContentType()</td></tr>");
>             out.println("<tr><th>Server name</th><td>" + request.getServerName()
+ "</td><td>request.getServerName()</td></tr>");
>             out.println("<tr><th>Server port</th><td>" + request.getServerPort()
+ "</td><td>request.getServerPort()</td></tr>");
>             out.println("<tr><th>Remote user</th><td>" + request.getRemoteUser()
+ "</td><td>request.getRemoteUser()</td></tr>");
>             out.println("<tr><th>Remote address</th><td>" + request.getRemoteAddr()
+ "</td><td>request.getRemoteAddr()</td></tr>");
>             out.println("<tr><th>Remote host</th><td>" + request.getRemoteHost()
+ "</td><td>request.getRemoteHost()</td></tr>");
>             out.println("<tr><th>Authorization scheme</th><td>"
+ request.getAuthType() + "</td><td>request.getAuthType()</td></tr>");
>             out.println("<tr><th colspan=\"3\">Request Headers</th></tr>");
>             for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();) {
>                 String key = (String) e.nextElement();
>                 String value = request.getHeader(key);
>                 out.println("<tr><th>" + key + "</th><td>" +
value + "</td><td>request.getHeader(\"" + key + "\")</td></tr>");
>             }
>             out.println("<tr><th colspan=\"3\">Request Parameters (form fields)</th></tr>");
>             for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
>                 String key = (String) e.nextElement();
>                 String value = request.getParameter(key);
>                 out.println("<tr><th>" + key + "</th><td>" +
value + "</td><td>request.getParameter(\"" + key + "\")</td></tr>");
>             }
>             out.println("</table>");
>         } catch (IOException ioe) {
>             ioe.printStackTrace();
>         }
>         return EVAL_PAGE;
>     }
> 
>     public void setParent(Tag parent) {
>         this.parent = parent;
>     }
> 
>     public void setBodyContent(BodyContent bodyOut) {
>         this.bodyOut = bodyOut;
>     }
> 
>     public void setPageContext(PageContext pageContext) {
>         this.pageContext = pageContext;
>     }
> 
>     public Tag getParent() {
>         return this.parent;
>     }
> 
>     public void release() {
>         bodyOut = null;
>         pageContext = null;
>         parent = null;
>     }
> 
>     protected BodyContent bodyOut;
>     protected PageContext pageContext;
>     protected Tag parent;
> 
> }

Mime
View raw message