Solved

jsp error report

Posted on 2004-04-30
21
372 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:VolSpeak
  • 10
  • 7
  • 4
21 Comments
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10961208
you can make an error page
Ghost
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10961243
0
 

Author Comment

by:VolSpeak
ID: 10961299
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
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10961328
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
 
LVL 7

Expert Comment

by:mark-b
ID: 10962073
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
 

Author Comment

by:VolSpeak
ID: 10962163

Im using the filename as a href so that wont work in my sisuations
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10962176
use my suggestion it will work
Ghost
0
 

Author Comment

by:VolSpeak
ID: 10962268

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

Author Comment

by:VolSpeak
ID: 10962309

copyPasteGhost: I would have to embed your code in an xsl stylesheet and i dont think jsp can be embedded in xsl.
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10962337
??? 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:VolSpeak
ID: 10962391

im using a stylesheet against a file and if its not found the error is displayed. I am using jsp with xsl.
0
 
LVL 13

Assisted Solution

by:copyPasteGhost
copyPasteGhost earned 25 total points
ID: 10962414
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
 
LVL 7

Accepted Solution

by:
mark-b earned 50 total points
ID: 10962500
You have to conform to the web.dtd (I think that is in your conf directory, next to the web.xml file).

-Mark
0
 

Author Comment

by:VolSpeak
ID: 10962552

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
 

Author Comment

by:VolSpeak
ID: 10962648

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
 

Author Comment

by:VolSpeak
ID: 10962708

>>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
 

Author Comment

by:VolSpeak
ID: 10962796

I got it :)
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10962803
what was it?
0
 
LVL 7

Expert Comment

by:mark-b
ID: 10962828
Yes:

<location>/notFound.jsp</location>

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

../yourwebapp/

not ../yourwebapp/WEB-INF/

-Mark
0
 
LVL 7

Expert Comment

by:mark-b
ID: 10962836
Oh.. Ok.  Good!
0
 

Author Comment

by:VolSpeak
ID: 10963194

>> what was it?

What Mark posted
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JTable - RowFilter & Columns Header. 3 140
java.util.concurrent.locks in java 3 186
java beans and EJBs 5 186
servlet cookie finding by name 1 70
There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
In 2017, ransomware will become so virulent and widespread that if you aren’t a victim yourself, you will know someone who is.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now