This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

process errors of user defined URL

 
Joshua Cloch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

When i am intended to input an invalid url like: http://www.javaranch.com

an error page is displayed with these content shown below:

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.
Error 404
saloon.javaranch.com
Apache/2.0.46 (CentOS)

Can I realise this in JSP, and how?

Thanks very much!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can declare custom error pages in the web.xml.
 
Joshua Cloch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, do you mean declare it like this in web.xml:

<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/errorpage.jsp</location>
</error-page>

<error-page>
<error-code>500</error-code>
<location>/errorpage.jsp</location>
</error-page>


I have done that,however, it only works when there is an exception being thrown.

If the user is intended to type a URL which doesnot exist,these information is shown below:

HTTP Status 404 - /test.jsp

type Status report

message /test.jsp

description The requested resource (/test.jsp) is not available.
Apache Tomcat/5.5.15

Yeah, these information is correct,but it is not friendly to the user. can the website redirect the user to an error page which prompts the user to use a valid URL?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error code for a page not found is 404.

 
Joshua Cloch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic