Skip navigation
nchipping
Currently Being Moderated

404 Custom Forwards

Aug 6, 2012 3:36 PM

Tags: #5.5 #cq5 #error#404

I have a custom 404 set up by following this:

 

http://dev.day.com/docs/en/cq/current/developing/customizing_error_han dler_pages.html

 

I changed it so that the default.jsp page will now FORWARD to my DYNAMIC 404.html page.  If I just allow it to stop at default.jsp, I have a 404 error code, but once it FORWARDs (not redirects), the new page that shows comes in as a 200 code.

 

How would I force the error code to be preserved, if forwarding the default.jsp to a content page (to keep the same dynamic content on all other pages)? I have the error code and response properly before forwarding (not redirecting), but once I get to the new page, it shows a status code of 200. Is there any way to force this? Disabling the CQ WCM Debug Filter doesn't change this for me.

 
Replies
  • Justin Klei
    40 posts
    Apr 14, 2009
    Currently Being Moderated
    Aug 8, 2012 1:31 PM   in reply to nchipping

    Can you post your code and explain what steps you took to implement this?  It doesn't sound like you followed the instructions properly.  If you're trying to implement a custom 404 error page, you should have a script called 404.jsp.

     
    |
    Mark as:
  • Justin Klei
    40 posts
    Apr 14, 2009
    Currently Being Moderated
    Aug 8, 2012 3:11 PM   in reply to nchipping

    There should be no default.jsp, just a 404.jsp.  I'm confused when you say "Once I had the 404.jsp that POINTS to the default.jsp".  Can you explain how you did this (exact steps)?

     

    Anyway, your content page that you forward to should have the following:

      response.setStatus(404);

     

    I'd recommend creating a new page component that contains this code.

     
    |
    Mark as:
  • Justin Klei
    40 posts
    Apr 14, 2009
    Currently Being Moderated
    Aug 9, 2012 11:56 AM   in reply to nchipping

    Okay, looks like default.jsp exists in CQ5.5 but not in CQ5.4.  Looks like default.jsp is a generic error handler if a specific one doesn't exist.

     

    What I think is probably going on in your case is something else is resetting the status to 200 as part of the resource resolution process for the new page.  What you probably should do is set the status in the new script you are redirecting to rather than trying to do it in the 404.jsp.  This makes sense anyway because what you are doing with the forward is delegating the handling of the response to some other servlet.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points