You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by thorsten schmid <ts...@novocron.de> on 2004/03/10 11:20:28 UTC

generating a 404 response in an xsp based pipeline

Hello,

Does anyone now how to generate a 404 error page in xsp?
We have an xsp-page searching a database for hits on clicked hyperlinks. 
Because the site is also visited by search engines, I want the server to 
respond with 404 status page as soon as the query returns no result.
Otherwise the webcrawler would spider several 'sorry no result found' - pages. 
That would not make any sense at all.

What I have been trying so far is to use the action logicsheet  to redirect to 
an unknown uri to let cocoon serve the error page. But the use of the action 
logicsheet is not allowed within a generator.

Does anyone have hints on how to solve the problem??
Best regards 
Thorsten



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: generating a 404 response in an xsp based pipeline

Posted by thorsten schmid <ts...@novocron.de>.
Hi John,

Thank you for your hint. I wrote an exception included it in my xsp and 
performed the necessary steps in the sitemap and IT WORKED.


For all people who have a similar problem I summarize te steps in detail:

My exception derived from  org.apache.cocoon.ProcessingException (see 
http://cocoon.apache.org/2.1/userdocs/concepts/errorhandling.html ):
package myPack;

import org.apache.cocoon.*;
import org.apache.avalon.framework.*;

public class MyEmptyResultException extends 
org.apache.cocoon.ProcessingException
{
  public MyEmptyResultException(String msg) { super(msg); }
}


My xsp:
     :
<xsp:structure>
   <xsp:include>MyPack.*</xsp:include>
</xsp:structure>
<xsp:logic>
     :
     :
  /*auxilliary method for throwing the exception*/
protected void throwMyEmptyResultException() throws MyEmptyResultException {
  throw new MyEmptyResultException("No results Found on your query");
}
     :
     :
</xsp:logic>
     :
     :
<esql:no-results>
  <xsp:logic>throwMyEmptyResultException();</xsp:logic>
</esql:no-results>
     :

The Sitemap:
     :
     :
<map:selector logger="sitemap.selector.exception" name="exception"
src="org.apache.cocoon.selection.ExceptionSelector">
     :
     :
   <exception class="MyPack.MyEmptyResultException" name="no-sql-results"/>
     :
     :
</map:selector>
     :
     :
     :
<map:handle-errors>
 <map:select type="exception">
   <map:when test="no-sql-results">
      <map:generate src="xml/error-not-found.xml"/>
      <map:transform src="xsl/error-not-found.xsl"/>
      <map:serialize status-code="404"/>
    </map:when>
  </map:select>
</map:handle-errors>
     :
     :
     :

_______________________________________________________

Am Mittwoch, 10. März 2004 11:41 schrieb John L. Webber:
> One way to solve the problem would be to throw a domain-specific
> exception in the generator and use a selector for this exception in the
> map:handle-errors for the pipeline. For example:
>
> <map:handle-errors>
>     <map:select type="exception">
>       <map:when test="our-custom-exception">
>         <map:generate src="niceerror.xsp" type="serverpages"/>
>         <map:transform src="html/site2html.xsl">
>           <map:parameter name="pageTitle" value=": Resource not found"/>
>         </map:transform>
>         <map:serialize status-code="404"/>
>     </map:when>
>  </map:select>
> </map:handle-errors>
>
> John
>
> thorsten schmid wrote:
> >Hello,
> >
> >Does anyone now how to generate a 404 error page in xsp?
> >We have an xsp-page searching a database for hits on clicked hyperlinks.
> >Because the site is also visited by search engines, I want the server to
> >respond with 404 status page as soon as the query returns no result.
> >Otherwise the webcrawler would spider several 'sorry no result found' -
> > pages. That would not make any sense at all.
> >
> >What I have been trying so far is to use the action logicsheet  to
> > redirect to an unknown uri to let cocoon serve the error page. But the
> > use of the action logicsheet is not allowed within a generator.
> >
> >Does anyone have hints on how to solve the problem??
> >Best regards
> >Thorsten
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >For additional commands, e-mail: users-help@cocoon.apache.org

-- 
Thorsten Schmid

NovoCron Technologies
Am Steg 3, 89231 Neu-Ulm
Fon: +49-731-9723757
Fax: +49-731-9723818
Mobil: +49-170-3021585
mailto:tschmid@novocron.de
www.novocron.de

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: generating a 404 response in an xsp based pipeline

Posted by "John L. Webber" <Jo...@jentro.com>.
One way to solve the problem would be to throw a domain-specific 
exception in the generator and use a selector for this exception in the 
map:handle-errors for the pipeline. For example:

<map:handle-errors>
    <map:select type="exception">
      <map:when test="our-custom-exception">
        <map:generate src="niceerror.xsp" type="serverpages"/>
        <map:transform src="html/site2html.xsl">
          <map:parameter name="pageTitle" value=": Resource not found"/>
        </map:transform>
        <map:serialize status-code="404"/>
    </map:when>
 </map:select>
</map:handle-errors>

John

thorsten schmid wrote:

>Hello,
>
>Does anyone now how to generate a 404 error page in xsp?
>We have an xsp-page searching a database for hits on clicked hyperlinks. 
>Because the site is also visited by search engines, I want the server to 
>respond with 404 status page as soon as the query returns no result.
>Otherwise the webcrawler would spider several 'sorry no result found' - pages. 
>That would not make any sense at all.
>
>What I have been trying so far is to use the action logicsheet  to redirect to 
>an unknown uri to let cocoon serve the error page. But the use of the action 
>logicsheet is not allowed within a generator.
>
>Does anyone have hints on how to solve the problem??
>Best regards 
>Thorsten
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>

-- 
---------------------------------------------------------
 Jentro Technologies GmbH
 John L. Webber, Software Development
---------------------------------------------------------
 Rosenheimer Str. 145e	    81671 München
 Tel. +49 89 189 169 80     mailto:John.Webber@jentro.com 
 Fax  +49 89 189 169 99     http://www.jentro.com
---------------------------------------------------------
NOTICE: The information contained in this e-mail is confidential or may otherwise be legally privileged. It is intended for the named recipient only. If you have received it in error, please notify us immediately by reply or by calling the telephone number above and delete this message and all its attachments without any use or further distribution of its contents. Please note that any unauthorised review, copying, disclosing or otherwise making use of the information is strictly prohibited. Thank you. 
---------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


AW: generating a 404 response in an xsp based pipeline

Posted by Marco Rolappe <m_...@web.de>.
hi thorsten,

you could redirect to an 'no-results-page' pipeline which serializes with a
status code of 404;

...
<map:match pattern="no-results">
	...
	<map:serialize type="html" status-code="404"/>
</map:match>
...

HTH

> -----Ursprungliche Nachricht-----
> Von: users-return-64348-m_rolappe=web.de@cocoon.apache.org
> [mailto:users-return-64348-m_rolappe=web.de@cocoon.apache.org]Im Auftrag
> von thorsten schmid
> Gesendet: Mittwoch, 10. Marz 2004 11:20
> An: users@cocoon.apache.org
> Betreff: generating a 404 response in an xsp based pipeline
>
>
> Hello,
>
> Does anyone now how to generate a 404 error page in xsp?
> We have an xsp-page searching a database for hits on clicked hyperlinks.
> Because the site is also visited by search engines, I want the server to
> respond with 404 status page as soon as the query returns no result.
> Otherwise the webcrawler would spider several 'sorry no result
> found' - pages.
> That would not make any sense at all.
>
> What I have been trying so far is to use the action logicsheet
> to redirect to
> an unknown uri to let cocoon serve the error page. But the use of
> the action
> logicsheet is not allowed within a generator.
>
> Does anyone have hints on how to solve the problem??
> Best regards
> Thorsten
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org