Practical mod_perl / HTML Version / books


previous page: E.3.3. Sending Emailpage up: HTML Version of the booknext page: E.3.5. Utilities Taglib

E.3.4. Handling Exceptions


Search







modperlbook.org


 HTML Version


 PDF Version


 Download Code


 Table of Contents


 Errata


 mod_perl2 User's Guide


 Sitemap





Add to Google



Creative Commons License


Written by
Eric Cholet (Logilune)
and Stas Bekman (StasoSphere).

Hosted by ibiblio.org.




























The exception taglib, AxKit::XSP::Exception, is used to catch exceptions. The syntax is very simple: rather than allowing different types of exceptions, it is currently a very simple try/catch block. To use the exceptions taglib, the following has to be added to httpd.conf:

AxAddXSPTaglib AxKit::XSP::Exception

Then you can implement form validation using exceptions, as Example E-6 demonstrates.

Example E-6. exceptiontaglib.xsp

<xsp:page
 xmlns:xsp="http://apache.org/xsp/core/v1"
 xmlns:param="http://axkit.org/NS/xsp/param/v1"
 xmlns:except="http://axkit.org/NS/xsp/exception/v1"
 language="Perl"
>
<page>
 # form validation:
 <except:try>
  <xsp:logic>
  if ((<param:number/> > 10) || (0 > <param:number/>)) {
    die "Number must be between 0 and 10";
  }
  if (!<param:name/>) {
    die "You must supply a name";
  }
  # Now do something with the params
  </xsp:logic>
  <p>Values saved successfully!</p>
  <except:catch>
   <p>Sorry, the values you entered were
      incorrect: <except:message/></p>
  </except:catch>
 </except:try>
</page>

The exact same try/catch (and message) tags can be used for sendmail and for ESQL (discussed in a moment).

 

Continue to:

  • prev: E.3.3. Sending Email
  • Table of Contents
  • next: E.3.5. Utilities Taglib

Tags

mod_perl, modperl, Apache, perl, cgi, html, mod_perl, e-commerce, scalability, free, open source, OSS, apache, squid, high availability, modperl, linux, unix, Web, www, mod_perl, webserver, admin, apache, book, webmaster, tools, modperl, guide, docs, documentation, help, mod_perl, perl, information, apache, script, errata, eric cholet, perl, apache, mod-perl, stas bekman, mod_perl, cool, perl, Apache, performance, speed, choice




Other projects to check out: meta-religion.com is for those interested in Religious, Spiritual and Esoteric Phenomena. i-want-a-better.com is a community of people discussing what they would like to be improved in their lives and things they use and interact with. You may also want to find a healer in your area or read articles on variety of topics.






TOP
previous page: E.3.3. Sending Emailpage up: HTML Version of the booknext page: E.3.5. Utilities Taglib

© 2007 StasoSphere

[ Privacy Policy ] [ Terms of Use ] [ About Authors ] [ Search ]

Last modified Wed May 7 06:27:44 2008