You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Götz Botterweck <bo...@iwi.uni-koblenz.de> on 2000/05/09 16:01:55 UTC
Exception handling OR How to abort XSP processing?
I'd like check some preconditions when running a XSP script.
For example something like this
<xsp:logic>
if( request.getParameter("formMode") == null ) {
// output error message "Required parameter
'formMode' was not provided."
// abort
}
...
</xsp:logic>
Is there some nice way to do this?
Thanks
Goetz
Re: Exception handling OR How to abort XSP processing?
Posted by Ricardo Rocha <ri...@apache.org>.
On Tue, 09 May 2000, G�tz Botterweck wrote:
> I'd like check some preconditions when running a XSP script.
> For example something like this
> <xsp:logic>
> if( request.getParameter("formMode") == null ) {
> // output error message "Required parameter
> 'formMode' was not provided."
> // abort
> }
> ...
> </xsp:logic>
> Is there some nice way to do this?
I see 2 ways to achieve this:
1) You may subject all markup generation to this particular condition
and return at the appropriate point if it's not met:
<xsp:page ...>
. . .
<page>
<xsp:logic>
if (request.getParameter("formMode") == null) {
<title>Required Parameter Missing</title>
<p>
<font color="red">
Required parameter "formMode" is missing, you moron!
</font>
</p>
return;
}
</xsp:logic>
<title>Normal Title</title>
<!-- Normal Stuff -->
. . .
</page>
</xsp:page>
2) You may redirect your request to an appropriate error page and
return:
<xsp:page ...>
. . .
<page>
<xsp:logic>
if (request.getParameter("formMode") == null) {
response.sendRedirect(
"error-page.xml?message=" +
URLEncoder.encode(
"Required parameter 'formMode' is missing, you moron!"
)
);
return;
}
</xsp:logic>
<title>Normal Title</title>
<!-- Normal Stuff -->
. . .
</page>
</xsp:page>