RE: How to configure a custom page for JSP 404 errors?

2001-07-31 Thread Gautam Sinha

Pierce Courtney wrote:

Thanks for your replies, but this simply does not work for me ..
.. .. ..
If anyone has actually gotten this to work on Tomcat 3.2.2,
Please let me know how you did it.

--
Since I needed to display a customized error page, and have it 
working for Tomcat 3.2.1, here are the steps:

Platform: Tomcat 3.2.1 on Windows 2000

1.Create a Java Server Page like below and
  place it in your web app context.
  Lets call it errorHandler.jsp.
  Lets put it in tomcat_home/webapps/myApp/errorHandler.jsp.

<%@ page language="java" %>
<%@ page isErrorPage="true" %>



This is a custom message



2. Add to your context specific web.xml the following
lines anywhere between the  and  tags.
(Not in tomcat_home/conf/web.xml).  If you do not have a
web.xml in your context, copy and paste the following code
in between  and  tags and create a 
tomcat_home/webapps/myApp/WEB-INF/web.xml, where your context
is called myApp.

  
  
404
/errorHandler.jsp
  

3. Restart tomcat. Type a non-existent URL using your context
(say http://localhost:8080/myApp/non-exist.jsp) which you are sure
results in an error code 404 File Not Found, and check that the custom
message appears instead.

Note: If you prefer, you may use a servlet instead of a JSP.  Make
sure you have the servlet defined and do not use the preceding "/"
in the  tag.  Use the servlet name instead of the JSP name.
Initially I implemented this using a servlet, but replaced it with a JSP.
I could not get this to work with plain html files.

You may also append the alternate form below if you want to replace
pages with errors resulting from servlet exceptions:

  
java.lang.Exception
/errorHandler.jsp
  

Hope that helps,

Gautam




RE: How to configure a custom page for JSP 404 errors?

2001-07-18 Thread Courtney, Pierce

Hello,

I have found a workaround for this problem.
You *can* configure Tomcat 3.2.2 to go to
a particular page in the case of a 404 (or
other error), with this tag:


404
/CustomDefault


But, the  has to be a *servlet*. 
JSP or HTML pages won't work. Also make sure
you register both a  and a 
 like this:



CustomDefault


yourPackage.CustomDefault


-2147483646





CustomDefault


/CustomDefault



If you would like  to be a
JSP or HTML page, the workaround is
this: Make your default servlet
redirect to your JSP or HTML page.
(For some reason a server-side forward
or include doesn't work either).
So, if you want to go to your own
"error.jsp" in the case of 404 errors,
the CustomDefault servlet would look
something like this:
--
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;

public class CustomDefault extends HttpServlet 
{
public void service(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException
{
response.sendRedirect("/error.jsp");
}

}
--

I hope this helps anyone dealing with this problem.

Pierce Courtney
[EMAIL PROTECTED]



-Original Message-
From: Courtney, Pierce 
Sent: Monday, July 09, 2001 3:38 PM
To: '[EMAIL PROTECTED]'
Subject: RE: How to configure a custom page for JSP 404 errors?


Ryan and Hunor (Hades),

Thanks for your replies, but this simply does not work for me (perhaps I'm
missing something... some other setting one must set in server.xml or
something?)
I created a simple error.jsp and put this snippet in the main web.xml in
/conf/ and also in the web.xml file for my specific webapp:


404
/error.jsp


I also set the isErrorPage tag in my error.jsp per Hunor's suggestion.

Also I searched harder through the Tomcat User archives, and there seem to
be many people who have tried and failed to use this feature. But I could
find no mention of anyone actually having used this feature... I'm getting
the impression that this feature is buggy or not implemented.

BTW, This feature works perfectly in Tomcat 4.0-b5.

If anyone has actually gotten this to work on Tomcat 3.2.2, please let me
know how you did it.

Thanks in advance,
-Pierce Courtney
[EMAIL PROTECTED]


-Original Message-
From: Hunor Nam [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 09, 2001 12:43 AM
To: [EMAIL PROTECTED]
Subject: RE: How to configure a custom page for JSP 404 errors?


You also MUST set in your "error page" the faloving tag: <%@ page
isErrorPage="true" %>
Hades

-Original Message-
From: Ryan Lubke [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 06, 2001 10:29 PM
To: [EMAIL PROTECTED]
Subject: Re: How to configure a custom page for JSP 404 errors?


Hi Pierce,

 From what I've been able to gather, you should be able to set
the error page using the  directive within the
deployment descriptor for a web app (web.xml).


404
/error.jsp


Looking through the bug database, there was an open issue
regarding the use of static html pages within the 
tag.  I'm uncertain at this time what release it's actually fixed
in, but if you try it and get a stacktrace, then I guess you know :)

The bug report can be found here:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=291

I did find this information in the archives.  
Try looking at the results of the following search:
http://mikal.org/interests/java/tomcat/archive/search?search=error+page+
custom+404

I'm sure those who are more experiences could expand/correct on this 
information.
Hope this helps.

-rl

Courtney, Pierce wrote:

>Hello,
>
>This question probably has come up before, I just can't find it in the
>archives
>
>I am using Tomcat 3.2.2 standalone (not with Apache).
>
>How can I configure a particular page (servlet, static html, or jsp) to
be
>the "default"
>page that comes up if the requested jsp is not found, instead of the
404
>error.
>In other words, if a user requests:
>http://myTomcatSite.com/somePage.jsp
>
>I want to have somePage.jsp come up if it exists.
>But if somePage.jsp does not exist, I *don't* want the default 404
error to
>be displayed. Instead I want some custom page (a servlet actually) to
be
>processed. I don't really care if this is achieved with a client-side
>redirect or a server-side include/forward.
>
>I have tried using the DefaultServlet, which doesn't seem to work. I
have
>also set up my own servlet against  /* .
This
>works for servlets only, not JSPs. It seems the basic problem is that
any
>URI that matches *.jsp. gets processed by the JspServlet

RE: How to configure a custom page for JSP 404 errors?

2001-07-09 Thread Courtney, Pierce

Ryan and Hunor (Hades),

Thanks for your replies, but this simply does not work for me (perhaps I'm
missing something... some other setting one must set in server.xml or
something?)
I created a simple error.jsp and put this snippet in the main web.xml in
/conf/ and also in the web.xml file for my specific webapp:


404
/error.jsp


I also set the isErrorPage tag in my error.jsp per Hunor's suggestion.

Also I searched harder through the Tomcat User archives, and there seem to
be many people who have tried and failed to use this feature. But I could
find no mention of anyone actually having used this feature... I'm getting
the impression that this feature is buggy or not implemented.

BTW, This feature works perfectly in Tomcat 4.0-b5.

If anyone has actually gotten this to work on Tomcat 3.2.2, please let me
know how you did it.

Thanks in advance,
-Pierce Courtney
[EMAIL PROTECTED]


-Original Message-
From: Hunor Nam [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 09, 2001 12:43 AM
To: [EMAIL PROTECTED]
Subject: RE: How to configure a custom page for JSP 404 errors?


You also MUST set in your "error page" the faloving tag: <%@ page
isErrorPage="true" %>
Hades

-Original Message-
From: Ryan Lubke [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 06, 2001 10:29 PM
To: [EMAIL PROTECTED]
Subject: Re: How to configure a custom page for JSP 404 errors?


Hi Pierce,

 From what I've been able to gather, you should be able to set
the error page using the  directive within the
deployment descriptor for a web app (web.xml).


404
/error.jsp


Looking through the bug database, there was an open issue
regarding the use of static html pages within the 
tag.  I'm uncertain at this time what release it's actually fixed
in, but if you try it and get a stacktrace, then I guess you know :)

The bug report can be found here:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=291

I did find this information in the archives.  
Try looking at the results of the following search:
http://mikal.org/interests/java/tomcat/archive/search?search=error+page+
custom+404

I'm sure those who are more experiences could expand/correct on this 
information.
Hope this helps.

-rl

Courtney, Pierce wrote:

>Hello,
>
>This question probably has come up before, I just can't find it in the
>archives
>
>I am using Tomcat 3.2.2 standalone (not with Apache).
>
>How can I configure a particular page (servlet, static html, or jsp) to
be
>the "default"
>page that comes up if the requested jsp is not found, instead of the
404
>error.
>In other words, if a user requests:
>http://myTomcatSite.com/somePage.jsp
>
>I want to have somePage.jsp come up if it exists.
>But if somePage.jsp does not exist, I *don't* want the default 404
error to
>be displayed. Instead I want some custom page (a servlet actually) to
be
>processed. I don't really care if this is achieved with a client-side
>redirect or a server-side include/forward.
>
>I have tried using the DefaultServlet, which doesn't seem to work. I
have
>also set up my own servlet against  /* .
This
>works for servlets only, not JSPs. It seems the basic problem is that
any
>URI that matches *.jsp. gets processed by the JspServlet.  So it is not
>determined if the .jsp file actually exists or not until the JspServlet
is
>triggered.
>
>Can this custom error page functionality be configured somehow in
Tomcat?
>
>Thanks for any help,
>Pierce Courtney
>[EMAIL PROTECTED]
>
>




RE: How to configure a custom page for JSP 404 errors?

2001-07-09 Thread Hunor Nam

You also MUST set in your "error page" the faloving tag: <%@ page
isErrorPage="true" %>
Hades

-Original Message-
From: Ryan Lubke [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 06, 2001 10:29 PM
To: [EMAIL PROTECTED]
Subject: Re: How to configure a custom page for JSP 404 errors?


Hi Pierce,

 From what I've been able to gather, you should be able to set
the error page using the  directive within the
deployment descriptor for a web app (web.xml).


404
/error.jsp


Looking through the bug database, there was an open issue
regarding the use of static html pages within the 
tag.  I'm uncertain at this time what release it's actually fixed
in, but if you try it and get a stacktrace, then I guess you know :)

The bug report can be found here:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=291

I did find this information in the archives.  
Try looking at the results of the following search:
http://mikal.org/interests/java/tomcat/archive/search?search=error+page+
custom+404

I'm sure those who are more experiences could expand/correct on this 
information.
Hope this helps.

-rl

Courtney, Pierce wrote:

>Hello,
>
>This question probably has come up before, I just can't find it in the
>archives
>
>I am using Tomcat 3.2.2 standalone (not with Apache).
>
>How can I configure a particular page (servlet, static html, or jsp) to
be
>the "default"
>page that comes up if the requested jsp is not found, instead of the
404
>error.
>In other words, if a user requests:
>http://myTomcatSite.com/somePage.jsp
>
>I want to have somePage.jsp come up if it exists.
>But if somePage.jsp does not exist, I *don't* want the default 404
error to
>be displayed. Instead I want some custom page (a servlet actually) to
be
>processed. I don't really care if this is achieved with a client-side
>redirect or a server-side include/forward.
>
>I have tried using the DefaultServlet, which doesn't seem to work. I
have
>also set up my own servlet against  /* .
This
>works for servlets only, not JSPs. It seems the basic problem is that
any
>URI that matches *.jsp. gets processed by the JspServlet.  So it is not
>determined if the .jsp file actually exists or not until the JspServlet
is
>triggered.
>
>Can this custom error page functionality be configured somehow in
Tomcat?
>
>Thanks for any help,
>Pierce Courtney
>[EMAIL PROTECTED]
>
>





Re: How to configure a custom page for JSP 404 errors?

2001-07-06 Thread Ryan Lubke

Hi Pierce,

 From what I've been able to gather, you should be able to set
the error page using the  directive within the
deployment descriptor for a web app (web.xml).


404
/error.jsp


Looking through the bug database, there was an open issue
regarding the use of static html pages within the 
tag.  I'm uncertain at this time what release it's actually fixed
in, but if you try it and get a stacktrace, then I guess you know :)

The bug report can be found here:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=291

I did find this information in the archives.  
Try looking at the results of the following search:
http://mikal.org/interests/java/tomcat/archive/search?search=error+page+custom+404

I'm sure those who are more experiences could expand/correct on this 
information.
Hope this helps.

-rl

Courtney, Pierce wrote:

>Hello,
>
>This question probably has come up before, I just can't find it in the
>archives
>
>I am using Tomcat 3.2.2 standalone (not with Apache).
>
>How can I configure a particular page (servlet, static html, or jsp) to be
>the "default"
>page that comes up if the requested jsp is not found, instead of the 404
>error.
>In other words, if a user requests:
>http://myTomcatSite.com/somePage.jsp
>
>I want to have somePage.jsp come up if it exists.
>But if somePage.jsp does not exist, I *don't* want the default 404 error to
>be displayed. Instead I want some custom page (a servlet actually) to be
>processed. I don't really care if this is achieved with a client-side
>redirect or a server-side include/forward.
>
>I have tried using the DefaultServlet, which doesn't seem to work. I have
>also set up my own servlet against  /* . This
>works for servlets only, not JSPs. It seems the basic problem is that any
>URI that matches *.jsp. gets processed by the JspServlet.  So it is not
>determined if the .jsp file actually exists or not until the JspServlet is
>triggered.
>
>Can this custom error page functionality be configured somehow in Tomcat?
>
>Thanks for any help,
>Pierce Courtney
>[EMAIL PROTECTED]
>
>





How to configure a custom page for JSP 404 errors?

2001-07-06 Thread Courtney, Pierce


Hello,

This question probably has come up before, I just can't find it in the
archives

I am using Tomcat 3.2.2 standalone (not with Apache).

How can I configure a particular page (servlet, static html, or jsp) to be
the "default"
page that comes up if the requested jsp is not found, instead of the 404
error.
In other words, if a user requests:
http://myTomcatSite.com/somePage.jsp

I want to have somePage.jsp come up if it exists.
But if somePage.jsp does not exist, I *don't* want the default 404 error to
be displayed. Instead I want some custom page (a servlet actually) to be
processed. I don't really care if this is achieved with a client-side
redirect or a server-side include/forward.

I have tried using the DefaultServlet, which doesn't seem to work. I have
also set up my own servlet against  /* . This
works for servlets only, not JSPs. It seems the basic problem is that any
URI that matches *.jsp. gets processed by the JspServlet.  So it is not
determined if the .jsp file actually exists or not until the JspServlet is
triggered.

Can this custom error page functionality be configured somehow in Tomcat?

Thanks for any help,
Pierce Courtney
[EMAIL PROTECTED]