Servlet API Conversion Details


Naming Conventions

Variable and method names use the fooBar capitalization style per the Java (TM) Servlet API specification.

Method Signatures

Java (TM) allow multiple signatures for each method, while Perl only allows one. Luckily, the Java (TM) API specifies few methods with multiple signatures, and those that do exist are easy to collapse into one method simply by allowing parameters to be optional and/or undef values. It turns out to be a non-issue.

Return Values

Return values are mapped from Java (TM) to the Perl API as such:

string, integer, etc.
These values are simple scalars, or undef.

boolean
These values are either 1 or undef.

arrays, enumerations
In list context, these values are arrays (possibly empty). In scalar context, the values are array references.

maps
In list context, these values are hashes (possibly empty). In scalar context, the values are hash references.

Interfaces

The Java (TM) version of the Servlet API is mostly comprised of interfaces. They cannot be instantiated directly but rather must be implemented by classes. Their function is to specify attributes and methods that must be provided by the implementation classes. Perl has no equivalent builtin mechanism, so we simply provide a package for the interface (to enable isa() type checking) and leave it to servlet container developers to provide implementations.

Exception Handling

The API uses Exception::Class for exceptions. It uses die() to throw them and eval() to catch them. Servlet::Util::Exception inherits from Exception::Class::Base and is itself the base class for all exceptions used by the Servlet API, whether part of the API specification or provided as utilities.

Event Handling

The API provides Servlet::Util::Event as a base class for event objects.

I/O

Perl's IO::Handle provides an excellent I/O subsystem with almost all of the functionality needed for input and output streams. It does not provide seeking functionality, leaving that to IO::Seekable, but I don't see that being a problem. Also, containers will likely provide instances of IO::Socket as input and output handles, at least some of the time, and that class is not seekable.

Locales

Character Encodings and Conversions

Threads