Package org.openqa.jetty.html

Examples of org.openqa.jetty.html.Table


        {
            page= new Page();
            page.title("Dump Servlet");

            page.add(new Heading(1, "Dump Servlet"));
            Table table= new Table(0).cellPadding(0).cellSpacing(0);
            page.add(table);
            table.newRow();
            table.addHeading("getMethod: ").cell().right();
            table.addCell("" + request.getMethod());
            table.newRow();
            table.addHeading("getContentLength: ").cell().right();
            table.addCell(Integer.toString(request.getContentLength()));
            table.newRow();
            table.addHeading("getContentType: ").cell().right();
            table.addCell("" + request.getContentType());
            table.newRow();
            table.addHeading("getCharacterEncoding: ").cell().right();
            table.addCell("" + request.getCharacterEncoding());
            table.newRow();
            table.addHeading("getRequestURI: ").cell().right();
            table.addCell("" + request.getRequestURI());
            table.newRow();
            table.addHeading("getRequestURL: ").cell().right();
            table.addCell("" + request.getRequestURL());
            table.newRow();
            table.addHeading("getContextPath: ").cell().right();
            table.addCell("" + request.getContextPath());
            table.newRow();
            table.addHeading("getServletPath: ").cell().right();
            table.addCell("" + request.getServletPath());
            table.newRow();
            table.addHeading("getPathInfo: ").cell().right();
            table.addCell("" + request.getPathInfo());
            table.newRow();
            table.addHeading("getPathTranslated: ").cell().right();
            table.addCell("" + request.getPathTranslated());
            table.newRow();
            table.addHeading("getQueryString: ").cell().right();
            table.addCell("" + request.getQueryString());

            table.newRow();
            table.addHeading("getProtocol: ").cell().right();
            table.addCell("" + request.getProtocol());
            table.newRow();
            table.addHeading("getScheme: ").cell().right();
            table.addCell("" + request.getScheme());
            table.newRow();
            table.addHeading("getServerName: ").cell().right();
            table.addCell("" + request.getServerName());
            table.newRow();
            table.addHeading("getServerPort: ").cell().right();
            table.addCell("" + Integer.toString(request.getServerPort()));
            table.newRow();
            table.addHeading("getLocalName: ").cell().right();
            table.addCell("" + request.getLocalName());
            table.newRow();
            table.addHeading("getLocalAddr: ").cell().right();
            table.addCell("" + request.getLocalAddr());
            table.newRow();
            table.addHeading("getLocalPort: ").cell().right();
            table.addCell("" + Integer.toString(request.getLocalPort()));
            table.newRow();
            table.addHeading("getRemoteUser: ").cell().right();
            table.addCell("" + request.getRemoteUser());
            table.newRow();
            table.addHeading("getRemoteAddr: ").cell().right();
            table.addCell("" + request.getRemoteAddr());
            table.newRow();
            table.addHeading("getRemoteHost: ").cell().right();
            table.addCell("" + request.getRemoteHost());
            table.newRow();
            table.addHeading("getRemotePort: ").cell().right();
            table.addCell("" + request.getRemotePort());
            table.newRow();
            table.addHeading("getRequestedSessionId: ").cell().right();
            table.addCell("" + request.getRequestedSessionId());
            table.newRow();
            table.addHeading("isSecure(): ").cell().right();
            table.addCell("" + request.isSecure());

            table.newRow();
            table.addHeading("isUserInRole(admin): ").cell().right();
            table.addCell("" + request.isUserInRole("admin"));

            table.newRow();
            table.addHeading("getLocale: ").cell().right();
            table.addCell("" + request.getLocale());

            Enumeration locales= request.getLocales();
            while (locales.hasMoreElements())
            {
                table.newRow();
                table.addHeading("getLocales: ").cell().right();
                table.addCell(locales.nextElement());
            }

            table.newRow();
            table
                .newHeading()
                .cell()
                .nest(new Font(2, true))
                .add("<BR>Other HTTP Headers")
                .attribute("COLSPAN", "2")
                .left();
            Enumeration h= request.getHeaderNames();
            String name;
            while (h.hasMoreElements())
            {
                name= (String)h.nextElement();

                Enumeration h2= request.getHeaders(name);
                while (h2.hasMoreElements())
                {
                    String hv= (String)h2.nextElement();
                    table.newRow();
                    table.addHeading(name + ":&nbsp;").cell().right();
                    table.addCell(hv);
                }
            }

            table.newRow();
            table
                .newHeading()
                .cell()
                .nest(new Font(2, true))
                .add("<BR>Request Parameters")
                .attribute("COLSPAN", "2")
                .left();
            h= request.getParameterNames();
            while (h.hasMoreElements())
            {
                name= (String)h.nextElement();
                table.newRow();
                table.addHeading(name + ":&nbsp;").cell().right();
                table.addCell(request.getParameter(name));
                String[] values= request.getParameterValues(name);
                if (values == null)
                {
                    table.newRow();
                    table.addHeading(name + " Values:&nbsp;").cell().right();
                    table.addCell("NULL!!!!!!!!!");
                }
                else
                    if (values.length > 1)
                    {
                        for (int i= 0; i < values.length; i++)
                        {
                            table.newRow();
                            table.addHeading(name + "[" + i + "]:&nbsp;").cell().right();
                            table.addCell(values[i]);
                        }
                    }
            }

            table.newRow();
            table
                .newHeading()
                .cell()
                .nest(new Font(2, true))
                .add("<BR>Cookies")
                .attribute("COLSPAN", "2")
                .left();
            Cookie[] cookies = request.getCookies();
            for (int i=0; cookies!=null && i<cookies.length;i++)
            {
                Cookie cookie = cookies[i];

                table.newRow();
                table.addHeading(cookie.getName() + ":&nbsp;").cell().attribute("VALIGN", "TOP").right();
                table.addCell(cookie.getValue());
            }
           
            /* ------------------------------------------------------------ */
            table.newRow();
            table
                .newHeading()
                .cell()
                .nest(new Font(2, true))
                .add("<BR>Request Attributes")
                .attribute("COLSPAN", "2")
                .left();
            Enumeration a= request.getAttributeNames();
            while (a.hasMoreElements())
            {
                name= (String)a.nextElement();
                table.newRow();
                table.addHeading(name + ":&nbsp;").cell().attribute("VALIGN", "TOP").right();
                table.addCell("<pre>" + toString(request.getAttribute(name)) + "</pre>");
            }           

            /* ------------------------------------------------------------ */
            table.newRow();
            table
                .newHeading()
                .cell()
                .nest(new Font(2, true))
                .add("<BR>Servlet InitParameters")
                .attribute("COLSPAN", "2")
                .left();
            a= getInitParameterNames();
            while (a.hasMoreElements())
            {
                name= (String)a.nextElement();
                table.newRow();
                table.addHeading(name + ":&nbsp;").cell().attribute("VALIGN", "TOP").right();
                table.addCell("<pre>" + toString(getInitParameter(name)) + "</pre>");
            }

            table.newRow();
            table
                .newHeading()
                .cell()
                .nest(new Font(2, true))
                .add("<BR>Context InitParameters")
                .attribute("COLSPAN", "2")
                .left();
            a= getServletContext().getInitParameterNames();
            while (a.hasMoreElements())
            {
                name= (String)a.nextElement();
                table.newRow();
                table.addHeading(name + ":&nbsp;").cell().attribute("VALIGN", "TOP").right();
                table.addCell("<pre>" + toString(getServletContext().getInitParameter(name)) + "</pre>");
            }

            table.newRow();
            table
                .newHeading()
                .cell()
                .nest(new Font(2, true))
                .add("<BR>Context Attributes")
                .attribute("COLSPAN", "2")
                .left();
            a= getServletContext().getAttributeNames();
            while (a.hasMoreElements())
            {
                name= (String)a.nextElement();
                table.newRow();
                table.addHeading(name + ":&nbsp;").cell().attribute("VALIGN", "TOP").right();
                table.addCell("<pre>" + toString(getServletContext().getAttribute(name)) + "</pre>");
            }

            if (request.getContentType() != null
                && request.getContentType().startsWith("multipart/form-data")
                && request.getContentLength() < 1000000)
            {
                MultiPartRequest multi= new MultiPartRequest(request);
                String[] parts= multi.getPartNames();

                table.newRow();
                table
                    .newHeading()
                    .cell()
                    .nest(new Font(2, true))
                    .add("<BR>Multi-part content")
                    .attribute("COLSPAN", "2")
                    .left();
                for (int p= 0; p < parts.length; p++)
                {
                    name= parts[p];
                    table.newRow();
                    table.addHeading(name + ":&nbsp;").cell().attribute("VALIGN", "TOP").right();
                    table.addCell("<pre>" + multi.getString(parts[p]) + "</pre>");
                }
            }

            String res= request.getParameter("resource");
            if (res != null && res.length() > 0)
            {
                table.newRow();
                table
                    .newHeading()
                    .cell()
                    .nest(new Font(2, true))
                    .add("<BR>Get Resource: " + res)
                    .attribute("COLSPAN", "2")
                    .left();

                table.newRow();
                table.addHeading("this.getClass():&nbsp;").cell().right();
                table.addCell("" + this.getClass().getResource(res));

                table.newRow();
                table.addHeading("this.getClass().getClassLoader():&nbsp;").cell().right();
                table.addCell("" + this.getClass().getClassLoader().getResource(res));

                table.newRow();
                table.addHeading("Thread.currentThread().getContextClassLoader():&nbsp;").cell().right();
                table.addCell("" + Thread.currentThread().getContextClassLoader().getResource(res));

                table.newRow();
                table.addHeading("getServletContext():&nbsp;").cell().right();
                try{table.addCell("" + getServletContext().getResource(res));}
                catch(Exception e) {table.addCell("" +e);}
            }
           

            /* ------------------------------------------------------------ */
            page.add(Break.para);
View Full Code Here

TOP

Related Classes of org.openqa.jetty.html.Table

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.