tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dola Woolfe <dolac...@yahoo.com>
Subject Re: Can a "return" statement cause a problem?
Date Fri, 04 Nov 2005 20:54:48 GMT
Sorry, forgot to paste.


package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import html.*;

public final class ErrorPage_jsp extends
org.apache.jasper.runtime.HttpJspBase
    implements
org.apache.jasper.runtime.JspSourceDependent {

  private static java.util.Vector _jspx_dependants;

  public java.util.List getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request,
HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    Throwable exception =
org.apache.jasper.runtime.JspRuntimeLibrary.getThrowable(request);
    if (exception != null) {
     
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this,
request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write('\r');
      out.write('\n');

String offendingPage =
request.getAttribute("javax.servlet.error.request_uri")
+ "?" + request.getQueryString();
try {
  if (exception instanceof
servlets.Authentication.Exception) {
    System.out.println("I'm here!!!!");
    out.println("<html>" + new
Forward("/applicaitona/LoginForm.jsp?Forward=" +
offendingPage.replaceAll("&", "AMERSAND"), 0) +
"</html>");
   
////////////////////////////////////////////////////////////////////////
    return;
////////////////////////////////////////////////////////////////
   
////////////////////////////////////////////////////////////////////////
  }

  else {
    String uri = (String)
request.getAttribute("request_uri");
    String url = "http://projectc" +
request.getAttribute("javax.servlet.error.request_uri")
+ "?" + request.getQueryString();
    String body = "The error occurred when viewing the
following page:\n" + url + "\n\nMy Comments:\n ";
    body = body.replaceAll("&", "%26").replaceAll(" ",
" ").replaceAll("%", "%25").replaceAll("\n",
"%0D%0A");
    //
    //    body = java.net.URLEncoder.encode(body);
    Table table = new Table()
    .pAddH("Date").pAddL(new java.util.Date()).pLN()
    .pAddH("Info").pAddL("An error has occurred, but
now we capture errors gracefully. If you belive that
this is a Project A error, please " +
    new
Anchor("mailto:pg@Companyinvest.com?Subject=Project A
Problem&Body=" + body, "ALERT PG by emailing him") +
".").pLN()
    .pAddH("Possible Resolution")
    .pAddL("For what it's worth, I'm passing to you
the name of the error produced by java, " +
    "which may give you some indication of what was
wrong:<br> " + new Text.Bold(exception)).pLN()
    .pAddH("What to do next")
    .pAddL("Visit the " + new
Anchor("/applicaitona/TroubleShooting.jsp",
"Troubleshooting") + "page to find out whether this is
a common problem.").pLN()
    .pAddH("Emergency").pAddL("If this is an emergency
contact PG at (917) 699 5105").pLN()
    ;


    table.pAddH("The following section<br>is intended
for PG").pSetSpan(1, 2).pLN();
    StackTraceElement[] ste =
exception.getStackTrace();
    for (int i = 0; i < ste.length; i++) {
      String className = ste[i].getClassName();

      if (className.startsWith("database") ||
      className.startsWith("contrib") ||
      className.startsWith("html") ||
      className.startsWith("servlets") ||
      className.startsWith("universe")) {

        String fileName = ste[i].getFileName();
        int n = ste[i].getLineNumber();

        String name = "C:/User/ProjectA/src/" +
className.substring(0,
className.lastIndexOf('.')).replace('.', '/')+ "/" +
ste[i].getFileName();

        Anchor emacsAnchor = new Anchor(name,
fileName);
        Anchor htmlAnchor = new
Anchor("UtilTextFileInATable.jsp?FileName=" +
name.replaceAll("/", "\\\\") + "&Highlight=" + n,
"(HTML View)");

        table.pAddH("" + i).pAddL(emacsAnchor + ",
line " + n + " " + htmlAnchor).pLN();
      } else if (className.endsWith("_jsp")) {
        String fileName = ste[i].getFileName();
        fileName =
fileName.substring(fileName.lastIndexOf('.') + 1) +
".java";

        int n = ste[i].getLineNumber();
        //          String name =
"C:/User/tomcat/work/DEFAULT/applicaitona/" +
fileName;
        String name =
"C:/User/tomcat/work/Catalina/localhost/applicaitona/org/apache/jsp/"
+ fileName;
        Anchor emacsAnchor = new Anchor(name,
fileName);
        Anchor htmlAnchor = new
Anchor("UtilTextFileInATable.jsp?FileName=" +
name.replaceAll("/", "\\\\") + "&Highlight=" + n,
"(HTML View)");
        table.pAddH("" + i).pAddL(emacsAnchor + ",
line  " + n + " " + htmlAnchor).pLN();

      }
      else
      table.pAddH("" + i).pAddL(ste[i].getClassName()
+ " " + ste[i].getMethodName() + " " +
ste[i].getFileName() + ", line " +
ste[i].getLineNumber()).pLN();
    }
    CompanyTemplate template = new CompanyTemplate("An
Error Has Occurred", table);
    Page pAgE = new Page(new CompanyFeel.Head("An
Error Has Occurred"), new Body(template));
    out.print(pAgE);
  }
}
catch (Exception e) {
  e.printStackTrace();
}

      out.write('\r');
      out.write('\n');
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null)
_jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null)
_jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message