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
VolSpeakAsked:
Who is Participating?
 
mark-bConnect With a Mentor Commented:
You have to conform to the web.dtd (I think that is in your conf directory, next to the web.xml file).

-Mark
0
 
copyPasteGhostCommented:
you can make an error page
Ghost
0
 
copyPasteGhostCommented:
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
VolSpeakAuthor Commented:
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
0
 
copyPasteGhostCommented:
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
%>
0
 
mark-bCommented:
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

0
 
VolSpeakAuthor Commented:

Im using the filename as a href so that wont work in my sisuations
0
 
copyPasteGhostCommented:
use my suggestion it will work
Ghost
0
 
VolSpeakAuthor Commented:

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

copyPasteGhost: I would have to embed your code in an xsl stylesheet and i dont think jsp can be embedded in xsl.
0
 
copyPasteGhostCommented:
??? 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
0
 
VolSpeakAuthor Commented:

im using a stylesheet against a file and if its not found the error is displayed. I am using jsp with xsl.
0
 
copyPasteGhostConnect With a Mentor Commented:
but wont it throw the error within the jsp page which means that you can catch it and then display an error page?

right?
Ghost
0
 
VolSpeakAuthor Commented:

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.
0
 
VolSpeakAuthor Commented:

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?
0
 
VolSpeakAuthor Commented:

>>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
0
 
VolSpeakAuthor Commented:

I got it :)
0
 
copyPasteGhostCommented:
what was it?
0
 
mark-bCommented:
Yes:

<location>/notFound.jsp</location>

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

../yourwebapp/

not ../yourwebapp/WEB-INF/

-Mark
0
 
mark-bCommented:
Oh.. Ok.  Good!
0
 
VolSpeakAuthor Commented:

>> what was it?

What Mark posted
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.