Solved

jsp error report

Posted on 2004-04-30
21
371 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
Comment Utility
you can make an error page
Ghost
0
 
LVL 13

Expert Comment

by:copyPasteGhost
Comment Utility
0
 

Author Comment

by:VolSpeak
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility

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

Expert Comment

by:copyPasteGhost
Comment Utility
use my suggestion it will work
Ghost
0
 

Author Comment

by:VolSpeak
Comment Utility

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

Author Comment

by:VolSpeak
Comment Utility

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
Comment Utility
??? 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:VolSpeak
Comment Utility

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

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

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

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

I got it :)
0
 
LVL 13

Expert Comment

by:copyPasteGhost
Comment Utility
what was it?
0
 
LVL 7

Expert Comment

by:mark-b
Comment Utility
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
Comment Utility
Oh.. Ok.  Good!
0
 

Author Comment

by:VolSpeak
Comment Utility

>> what was it?

What Mark posted
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
html form inside div 3 86
password protect pdf 11 72
build fail in maven project 11 170
How to Post an If Statement in JSP 3 45
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

8 Experts available now in Live!

Get 1:1 Help Now