|
AxKit::XSP::WebUtils - Utilities for building XSP web apps |
<web:env_param name="..." /><web:path_info/><web:query_string/><web:request_uri/><web:request_host/><web:server_root/><web:redirect><web:url_encode string="..."/><web:url_decode string="..."/><web:header>
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:
<xsp:page
language="Perl"
xmlns:xsp="http://apache.org/xsp/core/v1"
xmlns:web="http://axkit.org/NS/xsp/webutils/v1"
>
Then use the tags:
<web:redirect>
<web:uri>foo.xsp</web:uri>
</web:redirect>
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:
<web:env_param>
<web:name>PATH</web:name>
</web:env_param>
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>
<web:path_info/>Returns the current PATH_INFO value.
<web:query_string/>Returns the current query string
<web:request_uri/>Returns the full URI of the current request
<web:request_host/>This tag returns the end-user-visible name of this web service
Consider www.example.com 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.
<web:server_root/>Returns the server root directory, aka document root.
<web:redirect>This tag allows an XSP page to issue a redirect.
Parameters (can be attributes or child tags):
Example (uses XSP param taglib):
<web:redirect secure="yes">
<web:uri><param:goto/></web:uri>
</web:redirect>
<web:url_encode string="..."/>Encode the string using URL encoding according to the URI specification.
<web:url_decode string="..."/>Decode the URL encoded string.
<web:header>This tag allows you to get and set HTTP headers.
Parameters:
Example:
<p> Your browser is: <web:header name="HTTP_USER_AGENT"/> </p>
Matt Sergeant, matt@axkit.com
Original code by Steve Willer, steve@willer.cc
This software is Copyright 2001 AxKit.com 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.
|
AxKit::XSP::WebUtils - Utilities for building XSP web apps |