AxKit::XSP::WebUtils - Utilities for building XSP web apps


Add the taglib to AxKit (via httpd.conf or .htaccess):

    AxAddXSPTaglib AxKit::XSP::WebUtils

Add the web: namespace to your XSP <xsp:page> tag:


Then use the tags:



The XSP WebUtils taglib implements a number of features for building web applications with XSP. It makes things like redirects and getting/setting headers simple.


All of the below tags allow the parameters listed to be either passed as an attribute (e.g. <web:env_param name="PATH">), or as a child tag:


The latter method allows you to use XSP expressions for the values.

<web:env_param name="..." />

Fetch the environment variable specified with the name parameter.

  <b>Server admin: <web:env_param name="SERVER_ADMIN"/></b>


Returns the current PATH_INFO value.


Returns the current query string


Returns the requested URI minus optional query string


This tag returns the end-user-visible name of this web service

Consider on port 80. It is served by a number of machines named abs, legs, arms, pecs and foo1, on a diversity of ports. With a proxy server in front that monkies with the headers along the way. It turns out that, while writing a script, people often wonder "How do I figure out the name of the web service that's been accessed?". Various hacks with uname, hostname, HTTP headers, etc. ensue. This function is the answer to all your problems.


Returns the server root directory, aka document root.


This tag allows an XSP page to issue a redirect.

Parameters (can be attributes or child tags):

uri (required)

The uri to redirect to.

host (optional)

The host to redirect to.

secure (optional)

Set to "yes" if you wish to redirect to a secure (ssl/https) server.

Example (uses XSP param taglib):

  <web:redirect secure="yes">

<web:url_encode string="..."/>

Encode the string using URL encoding according to the URI specification.

<web:url_decode string="..."/>

Decode the URL encoded string.


This tag allows you to get and set HTTP headers.


name (required)

The name of the parameter. If only name is specified, you will get the value of the incoming HTTP header of the given name.

value (optional)

If you also specify a value parameter, then the tag will set the outgoing HTTP header to the given value.


  Your browser is: <web:header name="HTTP_USER_AGENT"/>


This tag allows you to set the reply status for the client request.


code (required)

The integer value of a valid HTTP status code.


Returns the name of the authenticated user.


If the current request is protected by Basic authentication, this tag will return the decoded password sent by the client.


This tag allows you to get the fully parsed URI for the current request. In contrast to <web:request_uri/> the parsed URI will always include things like scheme, hostname, or the querystring.


omit (optional)

Valid values: path, path_info, and query. If specified, the corresponding URL components will be ommited for the return value.


This tag allows you to get the fully parsed URI for the previous request. This can be useful in 403 error documents where it is required to post login information back to the originally requested URI.


omit (optional)

Valid values: path, path_info, and query. If specified, the corresponding URL components will be ommited for the return value.


  <p>Access Denied. Please login</p>
  <form method="post" name="login">
      <xsp:attribute name="action">
          <web:request_prev_parsed_uri omit="query"/>


Returns the URI of the previous request minus optional query string


Returns the query string of the previous request.

<web:request_prev_param name="...">

Returns the value of the requested CGI parameter of the previous request.


name (required)

The name of the parameter to be retrieved.

<web:match_useragent name="...">

Returns true if the User Agent pattern in name matches the current User Agent.


name (required)

A User Agent pattern string to be matched.


  if (!<web:match_useragent name="MSIE|Gecko|Lynx|Opera"/>) {
      <h1>Sorry, your Web browser is not supported.</h1>
  else {


Returns true if the current request comes in via SSL.


  if (!<web:is_https/>) {
      <xsp:attribute name="href">
      use secure connection


Returns true if the current request is the first internal request, returns false if the request is a sub-request or an internal redirect.


Returns the list of variants returned by mod_negotation in case of a 406 HTTP status code. Useful for 406 error documents.


  <h1>406 Not Acceptable</h1>
    An appropriate representation of the requested resource <web:request_prev_uri/>
    could not be found on this server.


Returns the value of the Apache "ServerAdmin" config directive.


Returns the last 'error-notes' entry set by Apache. Useful for verbose 500 error documents.


    <h1>Server Error</h1>

    <p>An error occured. If the problem persists, please contact <web:server_admin/>.</p>
    <p>Error Details:<br/>


Matt Sergeant,

Original code by Steve Willer,


This software is Copyright 2001 Ltd.

You may use or redistribute this software under the terms of either the Perl Artistic License, or the GPL version 2.0 or higher.