ePages 6.11.0 - DE_EPAGES/WebInterface/Servlet/BaseServlet.pm

Package DE_EPAGES::WebInterface::Servlet::BaseServlet

Provides basic functionality for handling of HTTP requests.

Functions

handle
handleRequest
init
new
redirect
request
requestHeaders
response
serverVariables
storeName

handle

Initializes request and response and calls handleRequest.

Syntax
$Servlet->handle($Request, $Response);
Input
$Request (object)
HTTP::Request object
$Response (object)
HTTP::Response object

handleRequest

Main function for handling the request. This method must be overloaded by any sub class. The overloaded method should use request and response to access the current request and response objects.

Syntax
$Servlet->handleRequest;

init

Initializes the servlet for a new request with parameters from the Servlet.conf configuration file.

Syntax
$Servlet->init( $hParams );
Input
$hParams (ref.hash.string)
hash with servlet parameters

new

Create a new servlet object.

Syntax
$Servlet = new DE_EPAGES::Presentation::Servlet::Permission;
Example
my $Servlet = DE_EPAGES::WebInterface::Servlet::BaseServlet->new;
Return
$Servlet (object)
blessed object

redirect

Redirects the browser to another URL.

Syntax
$Servlet->redirect( $Location );
$Servlet->redirect( $Location, $StatusCode );
Input
$Location (string)
target URL
$StatusCode (int)
(optional, default: 301) HTTP status code

request

Return the current request. This function must be called during the handleRequest method, otherwise it returns undef.

Syntax
$Request = $Servlet->request;
Example
my $Request = $Servlet->request;
Return
$Request (object)
HTTP::Request object

requestHeaders

Without parameter returns all HTTP request headers as hash ref.
With one parameter returns the value of one request header.

Syntax
$hHeaders = $Servlet->requestHeaders;
$Value= $Servlet->requestHeaders($Name);
Input
$Name (string)
(optional) name of the HTTP header
Return
$hHeaders (ref.hash)
all HTTP headers
$Value (string)
value of one HTTP header

response

Return the current response. This function must be called during the handleRequest method, otherwise it returns undef.

Syntax
$Response = $Servlet->response;
Example
my $Response = $Servlet->response;
Return
$Response (object)
HTTP::Response object

serverVariables

Without parameter returns the function cookies which was served by the request. On first run on servlet the form will be encoded.
With one parameter (name of server variable) the value of this key will be returned.

Syntax
$ServerVariables = $Servlet->serverVariables;
$ServerVariable = $Servlet->serverVariables($Name);
Input
$Name (string)
name of cookie (optional)
Return
$ServerVariables (ref.hash)
key value pairs (optional)
$ServerVariable (string)
value of given name (optional)

storeName

Returns the store name from the X-ePages-Store header. Returns undef if the header doe not exist.

Syntax
$Servlet->storeName;