Jen,

The question is are you trying to catch mistyped Struts URLS OR regular URL
resources such as JSPs, HTML, CSS, Javascript includes, Images, etc.?
For the former, you're barking up the wrong tree (see below).  For the
latter, your error-page code should work UNLESS those file types are NOT
being handled by your Java Server (perhaps locally by a front-end Apache?).

Some key documentation (uh, oh, I'm saying RTFM aren't I? LOL):
http://struts.apache.org/userGuide/building_controller.html#actionmapping

It explains a wonderful struts-config.xml Action Mapping feature:

unknown - Set to true if this action should be configured as the default for
this application, to handle all requests not handled by another action. Only
one action can be defined as a default within a single application.

So, if your URL is defined as http://www.yoursite.com/myapp/someAction.do
but the visitor ended up typing in a Struts URL you never configured in your
struts-config.xml file(s) such as
http://www.yoursite.com/myapp/someFraction.do, this struts-config.xml
mapping would catch it and other Struts URL mistypings:

<action name="default"
        path="/someFraction"
        unknown="true"
        forward="/error404.jsp" />

And yes, I have used the "unknown" parameter at least once in a Struts v1.1
deployment, though not recently.

Regards,
David

-----Original Message-----
From: Caroline Jen [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 16, 2004 9:34 AM
To: Struts Users Mailing List; Craig McClanahan
Subject: Re: How To Handle Mis-Typing of URL By Users


Hi, I prepared the error404.jsp (simply typed in a
warning sentence) and placed the file in the
AppName/WEB-INF/web.xml file this way:

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <error-page>
    <error-code>404</error-code>
    <location>/error404.jsp</location>
  </error-page>
  <!--  taglibs -->
  <taglib>
     <taglib-uri>/tags/struts-bean</taglib-uri>

<taglib-location>/WEB-INF/lib/struts-bean.tld</taglib-location>

  </taglib>

I tested mis-typing.  But, my sentence; i.e. the error
page that I prepared does not show up.

Would you be more clear about "map this condition
directly to a Struts action or URL mapped directly
to a servlet." in the servlet 2.4 environment?  I
still do not have any idea about how the mapping
should be done in the struts-config.xml file.



--- Craig McClanahan <[EMAIL PROTECTED]> wrote:

> On Wed, 15 Sep 2004 13:06:01 -0400, Bill Siggelkow
> <[EMAIL PROTECTED]> wrote:
> > Place this stancza below your welcome-file-list in
> your web.xml. You can
> > use a static HTML page or a JSP.
> >
> > <error-page>
> >      <error-code>404</error-code>
> >      <location>/error404.jsp</location>
> > </error-page>
> >
>
> In a servlet 2.4 environment, you could also map
> this condition
> directly to a Struts action or URL mapped directly
> to a servlet.
>
> > -Bill Siggelkow
> >
>
> Craig
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>




_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to