Link to home
Start Free TrialLog in
Avatar of VolSpeak
VolSpeak

asked on

jsp error report

Is there any way I can check for the error below before the error is displayed and redirect to a different page if it will be displayed.


HTTP Status 404 - //main//file.doc

type Status report

message //main//file.doc

description The requested resource (//main//file.doc) is not available.
Apache Tomcat/4.1.29
Avatar of copyPasteGhost
copyPasteGhost
Flag of Canada image

you can make an error page
Ghost
Avatar of VolSpeak
VolSpeak

ASKER

I dont think thats what im looking for.

>>description The requested resource (//main//file.doc) is not available.

This is a specific error to my web app , if this error is thrown the file has been deleted, i want to inform the user of this
why don't you use a try catch then
<%
try{
code that might throw the error

}
catch(Exception e){
%>
<jsp:forward page="myErrorPage.jsp" />
<%
}

in myErrorPage.jsp

you can have some lines of code to explain what happened.
Cheers,
Ghost
%>
I believe this is what you are looking for:

http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=56&t=000330

Basically, you have add something like this in your web.xml:

<error-page>
<error-code>404</error-code>
<location>/notFound.jsp</location>
</error-page>

-Mark


Im using the filename as a href so that wont work in my sisuations
use my suggestion it will work
Ghost

Mark: that would work for me, can I put that code anywhere in my web.xml?

copyPasteGhost: I would have to embed your code in an xsl stylesheet and i dont think jsp can be embedded in xsl.
??? xsl?
why did you post your question in the jsp section?
wouldn't the xml section have been better?

your error said you were using tomcat's server? if your not using jsp how is that possible?
Ghost

im using a stylesheet against a file and if its not found the error is displayed. I am using jsp with xsl.
SOLUTION
Avatar of copyPasteGhost
copyPasteGhost
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

The actual page the error is thrown on doesnt exist on my machine. Ideally I could do a check against the page and to see if it exists.

Ive amended my web.xml as shown but its not linking to my page of choice.

This XML file does not appear to have any style information associated with it. The document tree is shown below.
     
-
      <html>
<body/>
</html>

Do I have to specify the location somewhere else?

>>This XML file does not appear to have any style information associated with it. The document tree is shown below.
     
-
     <html>
<body/>
</html>

This is the error page it link to

I got it :)
what was it?
Yes:

<location>/notFound.jsp</location>

I believe you should place the 'notFound.jsp' in this directory:

../yourwebapp/

not ../yourwebapp/WEB-INF/

-Mark
Oh.. Ok.  Good!

>> what was it?

What Mark posted