Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

redirect if error 404 comes

 
Gaurav Chhabras
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI

now i try to do the following thing -:

i make a jsp page, give a hyperlink there to some page and i have not make that page.This means that it will give the error 404 i.e page not found.

Now in web.xml i have given -:

<web-app>
<error-page>
<error-code>404</error-code>
<location>/pagenotfound.jsp</location>
</error-page>
</web-app>

this means that as user clicks to my link and the page does not exist and then error 404 comes and then it will check in web.xml and rediect to the page defined in <location>/pagenotfound.jsp</location>.

But still my page is giving the error 404 page not found.
my project name is gaurav
i put a.jsp where i give the link, and put the web.xml in web-inf.

Now where should i put "pagenotfound.jsp", in gaurav or in web-inf\

please tell me the proper locations of all the files.


Thanks
Regards
Gaurav
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gaurav Chhabras:

<web-app>
<error-page>
<error-code>404</error-code>
<location>/pagenotfound.jsp</location>
</error-page>
</web-app>



Is that the entire contents of your web.xml file?
Also it really in a file named "web-inf"?
If so, it should be "WEB-INF".
 
Gaurav Chhabras
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response.

It is in WEB-INF and follwing is the full code -:


<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<error-page>
<error-code>404</error-code>
<location>/pagenotfound.jsp</location>
</error-page>

</web-app>


Thanks
Regards
Gaurav
 
Madhuri Chanda
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error page should not be in WEB-INF folder.. it has to be in the web folder (along with other jsp files ) where your WEB-INF folder is present.

WEB-INF folder contains .class files, .jar files, .xml files.

And I guess your web.xml file is not complete... I think you have to mention the servlet (<servlet>) and servlet mapping which handles the requests in your web.xml file.

Hope that helps.

Thanks,
Madhuri.
[ December 16, 2005: Message edited by: Madhuri Chanda ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Madhuri Chanda:
it has to be in the web folder (along with other jsp files ) where your WEB-INF folder is present.


Not correct. Though that is a frequently used location, it's not a "has to".
 
Madhuri Chanda
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the correction Bear.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default, Internet Explorer version 5 ignores server-generated error pages. So, depending on your browser, you may need to go to the Tools menu, select Internet Options, choose the Advanced tab, and make sure �Show friendly HTTP error messages� box is not checked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic