NAME
Apache2::ASP - ASP for a mod_perl2 environment.
SYNOPSIS
<html>
<body>
<%= "Hello, World!" %>
<br>
<%
for( 1...10 ) {
$Response->Write( "Hello from ASP ($_)<br>" );
}
%>
</body>
</html>
DESCRIPTION
Apache2::ASP is a new implementation of the ASP web programming for the mod_perl2 environment. Its aim is high performance, stability, scalability and ease of use.
Like other ASP web programming environments, Apache2::ASP offers the following top-level objects:
$Request
This object is a wrapper around the information passed to your code from the client.
It also handles cookies and uploads.
$Response
This object handles sending data and responses back to the client.
$Server
A wrapper around the Apache webserver.
$Session
Sessions are stored in a database. Currently MySQL and SQLite are supported.
$Application
The Application object is also stored in a database. Currently MySQL and SQLite are supported.
By storing data in the Application object you can share data with all processes and requests across the entire web application.
$Form
Apache2::ASP also provides the $Form
object - just a hashref of all the POST and GET data in one spot. This makes web pages easier to program.
INSTALLATION
% perl Makefile.PL
% make
% make test
% make install
Then, in your httpd.conf:
# Declare this important variable:
PerlSetEnv APACHE2_APPLICATION_ROOT /path/to/your/website
# Needed for CGI::Apache2::Wrapper to work properly:
LoadModule apreq_module /usr/local/apache2/modules/mod_apreq2.so
# Set the directory index:
DirectoryIndex index.asp
# Load up some important modules:
PerlModule Apache::DBI
PerlModule DBI
PerlModule DBD::mysql # or whatever database you will keep your session data in
PerlModule CGI::Apache2::Wrapper
PerlModule Apache2::ASP
PerlModule Apache2::Directive
PerlModule Apache2::RequestRec
PerlModule Apache2::RequestIO
PerlModule Apache2::Connection
PerlModule Apache2::SubRequest
# All *.asp files are handled by Apache2::ASP
<Files ~ (\.asp$)>
SetHandler perl-script
PerlHandler Apache2::ASP
</Files>
Then, in /path/to/your/website/conf
add the file apache2-asp-config.xml
. It will contain data like this:
<apache2-asp-config>
<db_user>mydbusername</db_user>
<db_pass>secret!password</db_pass>
<db_driver>mysql</db_driver>
<db_name>my_session_database</db_name>
<db_host>localhost</db_host>
<session_cookie_domain>.mywebsite.com</session_cookie_domain>
<session_cookie_name>session-id</session_cookie_name>
</apache2-asp-config>
Then, in your database, create a table with the following structure:
CREATE TABLE sessions (
session_id CHAR(32) PRIMARY KEY NOT NULL,
session_data BLOB,
created_on DATETIME,
modified_on DATETIME
);
Also create a table with the following structure:
CREATE TABLE asp_applications (
application_id VARCHAR(100) PRIMARY KEY NOT NULL,
application_data BLOB
);
Simply restart Apache and installation is complete. Now you need some ASP scripts.
If your website is in /var/www/html
then create a file "index.asp
" in /var/www/html
.
Your index.asp
could contain something like the following:
<html>
<body>
<%= "Hello, World!" %>
<br>
<%
for( 1...10 ) {
$Response->Write( "Hello from ASP ($_)<br>" );
}
%>
</body>
</html>
Then point your browser to http://yoursite.com/index.asp
and see what you get.
If everything was configured correctly, the output would look like:
Hello, World!
Hello from ASP (1)
Hello from ASP (2)
Hello from ASP (3)
Hello from ASP (4)
Hello from ASP (5)
Hello from ASP (6)
Hello from ASP (7)
Hello from ASP (8)
Hello from ASP (9)
Hello from ASP (10)
If you get an error instead, check out your error log to find out why.
AUTHOR
John Drago 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.