problems with custom error page in Q42004 Beta

Hi

I have a custom error page for a 404 code that is throwing the following exception.

The page is declared in web.xml as

<error-page>

<error-code>404</error-code>

<location>/error404.jsp</location>

</error-page>

I have a servlet that tesat for existance of the page I wish to include in my main JSP and if it is missing

it sends error. If it does exist then I proceed with dispatching it... Here is the snippet

if (nextURLExists){

Log.info(getClass(),"Forwarding..." + controlUrl);

request.getRequestDispatcher(controlUrl).forward(request, response);

}else{

response.sendError(HttpServletResponse.SC_NOT_FOUND);

}

Here is the exception thrown.....Can someone please demistify for me...

[#|2004-11-17T15:55:54.920-0500|SEVERE|sun-appserver-pe8.1|javax.enterpr

ise.

system.container.web|_Th

readID=16;|org.apache.catalina.core.StandardHostValve@1f33ecb: Exception

Processing ErrorPage[errorC

ode=404, location=/error404.jsp]

ClientAbortException: java.io.IOException: An existing connection was

forcibly closed by the remote

host

at

org.apache.coyote.tomcat5.OutputBuffer.realWriteBytes(OutputBuffer.java:

405)

at

org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:398)

at

org.apache.coyote.tomcat5.OutputBuffer.doFlush(OutputBuffer.java:347)

at

org.apache.coyote.tomcat5.OutputBuffer.flush(OutputBuffer.java:329)

at

org.apache.coyote.tomcat5.CoyoteResponse.flushBuffer(CoyoteResponse.java

:586

)

at

org.apache.coyote.tomcat5.CoyoteResponseFacade$1.run(CoyoteResponseFacad

e.ja

va:215)

at java.security.AccessController.doPrivileged(Native Method)

at

org.apache.coyote.tomcat5.CoyoteResponseFacade.flushBuffer(CoyoteRespons

eFac

ade.java:210)

at

org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java

:332

)

at

org.apache.catalina.core.StandardHostValve.postInvoke(StandardHostValve.

java

:177)

at

org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5

52)

at

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.

java

:132)

at

org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5

51)

at

org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)

at

org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)

at

com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(Processor

Task

.java:618)

at

com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(Processor

Task

.java:500)

at

com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask(ProcessorT

ask.

java:375)

at

com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.j

ava:

55)

|#]

[3339 byte] By [zambak] at [2007-9-30 22:29:19]
# 1
Just wanted to add thatif I refresh an existing page (F5 in MS IE) several times in a short time interval I also get this exception...Why is 404 mechanism being triggered on existing page?....Weird...Please helpZ....
zambak at 2007-7-7 12:52:36 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
What does your error404.jsp look like?
jluehe at 2007-7-7 12:52:36 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

My 404 page does the emailing of the refferer and some other data...Here is the top of the page which is the only part that is "dynamic"

<%@ page isErrorPage="true"%>

<%@ page import = "util.Utils"%>

<%

String strMsg = "";

String strQuery = request.getQueryString();

String strRef = request.getHeader("REFERER");

String strRefHost = request.getRemoteHost();

String strURI = request.getRequestURI();

String strURL = request.getRequestURL().toString();

String BASE_URL= "http://"+request.getServerName() + ":" + request.getServerPort()+ "/";

String RETURN_URL= "#";

// decide on return url for logo click

if ("INTRANET".equals( application.getInitParameter("app_type") ) )

RETURN_URL = "http://url1";

else

RETURN_URL = "http://url2";

//make sure query string is not null

if (strQuery == null)

strQuery = "";

else

strQuery = "?"+strQuery.trim();

// dont send email notification if missing resource is an image....

if (!(

strURL.toLowerCase().endsWith(".jpg") ||

strURL.toLowerCase().endsWith(".jpeg") ||

strURL.toLowerCase().endsWith(".gif") ||

strURL.toLowerCase().endsWith(".png") )

)

{

// if refferrer is null use default string

if (strRef==null)

strRef = "No Referrer (Request URL was probably typed in directly)";

// create message

strMsg = "Client Host: " + strRefHost + "\n"

+ "Referer URL: " + strRef + "\n"

+ "Request URL: " + strURL + strQuery + "\n";

// send an email to sysadmin

Utils.sendSysAdminEmail("[404 - Page Not Found] @ ["+BASE_URL+"]", strMsg);

}

%>

zambak at 2007-7-7 12:52:36 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

Hi,

Could you please let me know if your 404 page worked for you. I have been trying to send an email on missing images on an JSP page. I am struggling to find full path to missing image.I tried your code and all it does is send me path to the custom error page rather than the missing resource.

I would really appreciate it if you could let me know..

--Siva

spamati at 2007-7-7 12:52:36 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...