*
The moose likes JSP and the fly likes process errors of user defined URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "process errors of user defined URL" Watch "process errors of user defined URL" New topic
Author

process errors of user defined URL

Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
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!


truehh@hotmail.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

You can declare custom error pages in the web.xml.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
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

Joined: Dec 11, 2004
Posts: 13410

The error code for a page not found is 404.



Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
Thanks again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: process errors of user defined URL
 
Similar Threads
What is the difference in String a = "abc" and String a = new String("abc")
Please help with cascading menu!
Table space
An interesting question for Java Coders in the know!
Javascript, KeyEvents