All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openqa.jetty.servlet.Debug Maven / Gradle / Ivy

There is a newer version: 4.0.0-alpha-2
Show newest version
// ===========================================================================
// Copyright (c) 1996 Mort Bay Consulting Pty. Ltd. All rights reserved.
// $Id: Debug.java,v 1.10 2005/08/13 00:01:28 gregwilkins Exp $
// ---------------------------------------------------------------------------

package org.openqa.jetty.servlet;
import java.io.IOException;
import java.io.Writer;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.openqa.jetty.log.LogFactory;
import org.openqa.jetty.html.Block;
import org.openqa.jetty.html.Break;
import org.openqa.jetty.html.Font;
import org.openqa.jetty.html.Page;
import org.openqa.jetty.html.TableForm;
import org.openqa.jetty.log.LogImpl;
import org.openqa.jetty.log.LogSink;
import org.openqa.jetty.log.OutputStreamLogSink;


/* ------------------------------------------------------------ */
// Don't  write servlets like this one :-)
public class Debug extends HttpServlet
{    
    /* ------------------------------------------------------------ */
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response) 
        throws ServletException, IOException
    {
        Page page= new Page();
        page.title(getServletInfo());
        page.attribute("text","#000000");
        page.attribute(Page.BGCOLOR,"#FFFFFF");
        page.attribute("link","#606CC0");
        page.attribute("vlink","#606CC0");
        page.attribute("alink","#606CC0");


        Log l = LogFactory.getLog(Debug.class);
        
        if (!(l instanceof LogImpl))
            return;
        LogImpl log = (LogImpl) l;
        
        
        TableForm tf = new TableForm(request.getRequestURI());
        page.add(tf);
        tf.table().newRow().addCell(new Block(Block.Bold)
            .add(new Font(3,true).add(getServletInfo()))).cell().attribute("COLSPAN","2");
        tf.table().add(Break.rule);
        
        tf.addCheckbox("D","Debug On",log.getDebug());
        tf.addTextField("V","Verbosity Level",6,""+log.getVerbose());
        tf.addTextField("P","Debug Patterns",40,log.getDebugPatterns());
        tf.addCheckbox("W","Suppress Warnings",log.getSuppressWarnings());

        
        LogSink[] sinks = log.getLogSinks();
        for (int s=0;sinks!=null && sLog Sink "+s+":0)
                log.setVerbose(Integer.parseInt(v));
            else
                log.setVerbose(0);
            log.setDebugPatterns(request.getParameter("P"));


            LogSink[] sinks = log.getLogSinks();
            for (int s=0;sinks!=null && s




© 2015 - 2024 Weber Informatics LLC | Privacy Policy