Solprovider Lenya Kongregate Registration for Free Flash Games and Chat with solprovider

How to use ServerPages (XSP) in your Publication

There are two files involved in using a ServerPage.

1. An XMAP file calls the ServerPage with this line:
<map:generate type="serverpages" src="myServerPage.xsp"/>

2. Create the Serverpage "myServerPage.xsp".
<?xml version="1.0"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp">
<xsp:structure>
<xsp:include>java.util.Date</xsp:include>
</xsp:structure>
<now>
<xsp:logic>
Date date = new Date();
</xsp:logic>
<date><xsp:expr>date</xsp:expr></date>
</now>
</xsp:page>

Explanation


<?xml version="1.0"?>
A ServerPage is XML.

<xsp:page language="java" xmlns:xsp="http://apache.org/xsp">
ServerPages must contain the top-level tag "xsp:page" which defines the language and namespaces.

<xsp:structure>
<xsp:include>java.util.Date</xsp:include>
</xsp:structure>

The "xsp:structure" and "xsp:include" elements replace the "import" lines in normal Java.

<now>
The top-level element for the result.

<xsp:logic>
Date date = new Date();
</xsp:logic>

"xsp:logic" elements enclose Java code. They should not enclose elements for the result.

It best to keep the <xsp:logic> and </xsp:logic> lines at the beginning of the line without any indentation. They are more structural than part of the code, and indenting them with the code is difficult to maintain as the code changes, useless because they do not define code blocks, and detrimental because it is much less obvious if a line is inside or outside a logic section.

<date><xsp:expr>date</xsp:expr></date>
Add elements to the result.
"xsp:expr" elements enclose simple Java expressions. They are typically a variable name, but they can include a function like "date.toString()".

</now>
Close the top-level element for the result.

</xsp:page>
Close the top-level element of the ServerPage.

<< ServerPagesWarning >>

Contact Solprovider
Paul Ercolino