Pas Server Pages

Pas server pages are modled as text files with embedded Perl code in them. They are typicly used to produce HTML, though they are capable of producing any MIME content type including, but not limited to, text/xml, text/plain, image/jpg, and image/png.

PSPs use a syntax very similar to that of other embeded HTML languages. The embedded Perl code is surounded by <% and %> tags. Any content in the PSP file that is not within the <% and %> tags will not be processed by the PSP compiler. Any such content will become part of the output produced when the PSP is executed.

PSP by itself is really very simple. The fastest way to get familliar with it is to just start with an example. This example displays the current date and time:

<H1>The Current Time</H1>
  The current time is: <%= scalar(localtime()); %>

Past the obvious similarity to other embeded HTML languages, PSP begins to diverge. PSPs are compiled into a Pas Page object. The content of the PSP page is then reqpresented in the Page object's execute method. This methodology of compiling the PSP into a Perl program which is executed to produce the output of the PSP is one of the strengths of the PSP system. This approach takes full advantage of Perl's parser and syntax checking. Errors are reported relative to the location of the code PSP page instead of an anonymous evaluated expression, as with some other embeded Perl in HTML toolsets.

PSP Tags

There are two major types of PSP tags. Page directives and scripting tags. All PSP tags have the form <% ...code... %>. Page directives begin with an @ character, while scripting tags can start with any of several characters..


  my $firstName = $self->query->param('firstName');

<H1>Logicly, this is a test</H1>
<% if($firstName) { %>
  Welcome, <b><%= $firstName %></b>.
<% } else { %>
  I'm sorry, you don't seem to have a first name.
<% } %>

The scriptlet construct allows the declaration of variables, as well as the inclusion of branching logic into the PSP page. Scriptles may span content areas. This allows you to conditinaly emit content. Scriptlets can also be to prepare data that will be emitted by an expression.

Method Declarations

Account status for: <%= $self->displayName() %> <BR>
  sub displayName
    my($self) = @_;
    my $first  = $self->query->param('firstName');
    my $middle = $self->query->param('middleName');
    my $last   = $self->query->param('lastName');
    return "$last, $first $middle";

Method declarations will add a new method to the generated page object, which can then be called from within the PSP. This tag can also be used to override methods from the parent object of the PSP page. You can not use this method to override the execute() method of the current PSP page.

Page Directives


<%@ page info = "descriptive text" %>