File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes error-page declaration in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "error-page declaration in web.xml" Watch "error-page declaration in web.xml" New topic
Author

error-page declaration in web.xml

Gaurav Chugh
Ranch Hand

Joined: Aug 28, 2001
Posts: 50
hi there,
i am using the error-page declarative in web.xml in this way
<web-app>
<error-page>
<error-code>404</erro-code>
<location>/examples/jsp/ErrorPage.html</location>
</error-page>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>/MyServlet</servlet>
</servlet>
</web-app>
i am getting the error on server cmd prompt as "web-app" does not allow "servlet" here .so cud any body tell me what cud be the problem and where i did the mistake .i want to call the ErrorPage.html whenever the 404 (file Not Found) occur .
Thanks in advance.


------------------
with warm regards
..gaurav


Regards<br />gaurav..
patel sanjay
Greenhorn

Joined: Aug 28, 2001
Posts: 5
hallo,
if you are using tomcat 3.X, then
try using 2.3 spec.I mean
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">

Gruss
sanjay

Gaurav Chugh
Ranch Hand

Joined: Aug 28, 2001
Posts: 50
Hi snajay
i am using Tomcat 4.0 b6 , i did no tget u properly what do u wanna to say. everything is like that only , i am not satisfy abt the answere. plz clear to me .
Thanks in advance
------------------
with warm regards
..gaurav
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
The DTD describes which elements are required in an xml file. they also show the order the must appear in!
< !ELEMENT web-app (icon?, display-name?, description?, distributable?, context-param*, filter*, filter-mapping*, listener*, servlet*, servlet-mapping*, session-config?,
mime-mapping*, welcome-file-list?, error-page*, taglib*,
resource-env-ref*, resource-ref*, security-constraint*, login-config?, security-role*,
env-entry*, ejb-ref*, ejb-local-ref*) >
As you see servlet is before error page so, in your xml all entries for servlet must be before any entry for error page.

------------------
I Hope This Helps
Carl Trusiak, SCJP2
[This message has been edited by Carl Trusiak (edited September 09, 2001).]


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Gaurav Chugh
Ranch Hand

Joined: Aug 28, 2001
Posts: 50
Hi there
thanks carl, its solved my that problem, now i am following that sequence ,the problem is over but still i am not getting the error-page whenever the error occur , cud u tell me where i am burning myself , the problem may be in specifying the location. i have the error page ErrorPage.html in the given dir as
examples/jsp/ErrorPage.html
and i am specifying in web.xml as
<location>/examples/jsp/ErrorPage.html</location>
cud u tell me whether i specified it correctly or not , but i am not receiving the error page whenever the error occur and there is no othere error-code code i specified in web.xml, i just specified 404 .plz help me and tell me where i am doing the mistake .
thanks in advance

------------------
with warm regards
..gaurav
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
I can only assume from what you have that your webapp is examples.
If this is the case, your url to your error page needs to be relative to your webapp. In other words, it doesn't need /examples change this entry to <location/jsp/ErrorPage.html</location> And if my assumptions are correct, this will work.

------------------
I Hope This Helps
Carl Trusiak, SCJP2
Gaurav Chugh
Ranch Hand

Joined: Aug 28, 2001
Posts: 50
Hi There,
Thanks a lot Carl , now its working fine and ur asumption was absoultely correct .

------------------
with warm regards
..gaurav
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error-page declaration in web.xml