Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Apache2::ASP::Manual::Handlers
Documentation about writing Handlers

Apache2::ASP::Manual::Handlers - Documentation about writing Handlers


NAME

Apache2::ASP::Manual::Handlers - Documentation about writing Handlers


SYNOPSIS

Here is a basic handler:


  package MyHandler;

  

  use strict;

  use warnings 'all';

  use base 'Apache2::ASP::FormHandler';

  

  use vars qw(

    $Request $Response

    $Session $Server

    $Application $Form

    $Config

  );

  

  sub run

  {

    # Perform some work, then:

    $Response->Redirect("/another-page.asp");

  }# end run()

  

  1;# return true:


INTRODUCTION

What are Handlers?

Handlers are a kind of middle-ground for ASP programmers. There are no <% %> tags and no HTML parsing, but you still have the ASP objects ($Request, $Response, $Session, etc).

What makes them special?

Handlers are an object-oriented approach to form processing in a web application.

This means that Handlers that derive from one root Handler class will have different properties than Handlers that derive from another root Handler class.

What are Handlers for?

Handlers are intended for processing forms or responding to AJAX Web2.0 applications where you don't need to worry about large chunks of HTML embedded in your code.

What kinds of Handlers are there?

Handlers can subclass the following root classes:

Apache2::ASP::FormHandler
Subclasses of the Apache2::ASP::FormHandler manpage are used for processing form input. Typically a FormHandler will redirect the user to another page after the request has been processed.

Apache2::ASP::UploadHandler
Subclasses of the Apache2::ASP::UploadHandler manpage are used for processing file uploads. Unless you need to start completely from scratch, you're probably better off subclassing the Apache2::ASP::MediaManager manpage.

Apache2::ASP::MediaManager
Subclasses of the Apache2::ASP::MediaManager manpage get instant file-upload manager functionality just by showing up. Override a method or two and you've got basic file management that should work fine for most small websites. Override a couple more methods and you can have enterprise-class file management.

Apache2::ASP::PageHandler
All ASP scripts are compiled into a Perl module that subclasses the Apache2::ASP::PageHandler manpage.

Learn more about ASP compilation at the Apache2::ASP::Manual::ASP_Compilation manpage.


SUBCLASSING OTHER HANDLERS

All Handlers are subclasses of the Apache2::ASP::Handler manpage. the Apache2::ASP::MediaManager manpage is a subclass of the Apache2::ASP::UploadHandler manpage.

You could make your own ``private'' Handler classes (not installed under /handlers on your site) that your ``public'' Handlers (available under /handlers on your site) derive from.

For example, one could write an abstract ``shopping cart'' Handler that others are derived from, only adding or replacing functionality specific to their needs.

So Generic::Handler::Newsletter::Signup might contain all the logic necessary to add someone to a mailing list (in general). Newsletter::Signup could subclass Generic::Handler::Newsletter::Signup and handle the redirect part.

Example


  package Newsletter::Signup;

  

  use strict;

  use warnings 'all';

  use base 'Generic::Handler::Newsletter::Signup';

  use vars qw(

    $Request $Response

    $Session $Server

    $Application $Form

    $Config

  );

  

  sub run

  {

    my $s = shift;

    

    # Have Generic::Handler::Newsletter::Signup do the heavy lifting:

    $s->SUPER::run( @_ );

    

    # Now just redirect the user:

    $Response->Redirect("/thank-you.asp");

  }# end run()

  

  1;# return true:


READ THIS

Please note - your Handlers are not automatically reloaded if you make changes to them.

You will have to restart Apache to make sure that your changes take effect.

On a strictly development webserver you could use the Apache::Reload manpage to help this, but even then you may get some strange behavior.


BUGS

It's possible that some bugs have found their way into this release.

Use RT http://rt.cpan.org/NoAuth/Bugs.html to submit bug reports.


HOMEPAGE

Please visit the Apache2::ASP homepage at http://apache2-asp.no-ip.org/ to see examples of Apache2::ASP in action.


AUTHOR

John Drago mailto:jdrago_999@yahoo.com


COPYRIGHT AND LICENSE

Copyright 2007 John Drago, All rights reserved.

This software is free software. It may be used and distributed under the same terms as Perl itself.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy