File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes <error-page> tag in web.xml is not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "<error-page> tag in web.xml is not working " Watch "<error-page> tag in web.xml is not working " New topic
Author

<error-page> tag in web.xml is not working

Ruturaj Varne
Greenhorn

Joined: Jan 13, 2010
Posts: 8
Hi,

Following tag in web.xml is not working for me. I am using Tomcat 5.5 and JDK 5.

<error-page>
<exception-type>java.lang.NullPointerException</exception-type>
<location>/UserAuthentication/error.html</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/UserAuthentication/error.html</location>
</error-page>

Instead of showing the error.html, I am getting 404 Page not found on Browser.

Please guide me on this.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Details. We always need details!

Which browser? If it's IE, that's a known problem with IE.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ruturaj Varne
Greenhorn

Joined: Jan 13, 2010
Posts: 8
Yes.. It is IE 7. But I tried the same thing on Mozilla Firefox Browser also and getting the same result.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Does the file /UserAuthentication/error.html exist relative to the context root?
Ruturaj Varne
Greenhorn

Joined: Jan 13, 2010
Posts: 8
yes.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Then it should work.

If all you are going to give is single-word answers, there's not much else to say.
Ruturaj Varne
Greenhorn

Joined: Jan 13, 2010
Posts: 8
Well, I placed error.html inside the Userauthentication directory of Tomcat/ Webapps. I thought that /UserAuthentication/error.html will not work. So hit this link in browser just to confirm that the path is correct. I read one thread in this forum which tells that there is need of change in configuration of IE. That also i tried but the output is same. BLANK PAGE. So i think everything is at its proper place. So i am confused now and having only one question in mind that WHY THIS IS NOT WORKING.
I am expecting whenever there is 404 error then browser should show me the error.html. But it is not showing anything. Now please tell me.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Ruturaj Varne wrote:Well, I placed error.html inside the Userauthentication directory of Tomcat/ Webapps.

Then you answered my question incorrectly. The file path is not relative to the context root. This is why a single-word answer isn't a good idea.

If /UserAuthentication is the context path, it doesn't get specified as part of the file path. The container knowns where the context path is; you don't repeat it.
Ruturaj Varne
Greenhorn

Joined: Jan 13, 2010
Posts: 8
Now i tried the following

<error-page>
<exception-type>java.lang.NullPointerException</exception-type>
<location>/error.html</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.html</location>
</error-page>

Still it is not working.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

You changed 404 to 500. Are you seriously looking for help, or just yanking chains?
Ruturaj Varne
Greenhorn

Joined: Jan 13, 2010
Posts: 8
I added both of them (404 and 500). I am just doing some R&D work so that this <error-page> thing will work. Thats why i added 500.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

You'll need to post your web app file structure and the deployment descriptor. Please be sure to use code tags to preserve formatting.
Ruturaj Varne
Greenhorn

Joined: Jan 13, 2010
Posts: 8
send me your mail id ... i will send you everything..
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

UseTheForumNotEmail. You'll get more help by posting your directory structure and deployment descriptor here.


[My Blog]
All roads lead to JavaRanch
Ruturaj Varne
Greenhorn

Joined: Jan 13, 2010
Posts: 8
Here is an attachment of web.xml.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

You cannot attach such file. Please copy/paste it here. (Insert it between [code] [/code] tags)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <error-page> tag in web.xml is not working