James,

I'm running Magnolia 3.0RC4 on Tomcat 5.5 - the system's running stable,
so there's no reason to upgrade - although I'm in the process of setting
up a new environment, for which I'll obviously want to use the latest
version.

Anyway, I've set up one, and it works like a charm. I've created a
directory called "error" directly under the context root
("magnoliaAuthor", "magnolia Public", "ROOT", or whatever), and placed a
404.jsp in it.

In the application's web.xml (_NOT_ the web.xml in "tomcat/conf"), I've
added

  <error-page>
    <error-code>404</error-code>
    <location>/error/404.jsp</location>
  </error-page>

Restart Tomcat, and hey presto - instant 404!  :o)

Your configuration is essentially asking the app server to redirect to
the root "/" on encountering a 404. Since there's no page by default, it
displays the directory listing as the next best thing.

BTW, in a production environment, it is good practice to disable the
directory listing (it's enabled by default). If you're running Tomcat,
go to tomcat/conf/ and open web.xml. Search for 

        <init-param>
            <param-name>listings</param-name>
            <param-value>true</param-value>
        </init-param>

And change 
                <param-value>true</param-value>
to 
                <param-value>false</param-value>

Again, restart Tomcat and you're off.

Hope this helps.

Frank.

-----------
Frank Sattler
Celona Technologies
frank.sattler [at] celona.com
www.celona.com



-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] 
Sent: 02 March 2007 00:26
To: [email protected]
Subject: [magnolia-user] 404 handler in Magnolia 3?

This trick no longer works with Magnolia 3:

http://www.magnolia.info/wiki/Wiki.jsp?page=Setup404Handler

It does something though.  If I set up web.xml to this:

<error-page>
<error-code>404</error-code>
<location>/</location>
</error-page>

It gives me a directory listing (ooh bad).

If I give it a jsp template like the one at the bottom of this email it
doesn't load.  The catalina.log says:

ERROR  info.magnolia.context.MgnlContext MgnlContext.java(getInstance: 
289) 01.03.2007 17:23:11  MgnlContext is not initialized, This could
happen if the request does not go through magnolia default filters

I noticed an email in the user list archives about filters and 404, but
I have no idea what filters are.  Can someone explain how to make a
custom 404 page in Magnolia 3?

--

Thanks,

James Reynolds - University of Utah - Student Computing Labs -
801-585-9811
james(a)scl.utah.edu - james(a)magnusviri.com - http://
james.magnusviri.com






<jsp:root version="2.0" xmlns:jsp="http://java.sun.com/JSP/Page";  
xmlns:c="urn:jsptld:http://java.sun.com/jsp/jstl/core";
     xmlns:fmt="urn:jsptld:http://java.sun.com/jsp/jstl/fmt";  
xmlns:cms="urn:jsptld:cms-taglib">
     <jsp:directive.page contentType="text/html; charset=UTF-8" />
     <html>
     <head>
     <title>404 Error</title>
     <cms:links adminOnly="false" />
     </head>
     <body class="mgnlBgLight">
     <h3>404 Error</h3>

     <jsp:scriptlet>
        response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
        String contextName = request.getContextPath();
        String newLocn = contextName + "/404.html";
        response.setHeader("Location",newLocn);
     </jsp:scriptlet>

     </body>
     </html>
</jsp:root>

----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/developer.html
----------------------------------------------------------------

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/developer.html
----------------------------------------------------------------

Reply via email to