To read values from flowscript, you can use the JX Template Generator. But unlike Cocoon 2.1 and earlier versions you shouldn't have an explicit reference to org.apache.cocoon.generation.JXTemplateGenerator in the map:generator-section of your sitemap.
For future reference, here's the solution (using Apache Cocoon 2.2 and Maven 3.0.4):
1) Make sure your pom.xml has a dependency to cocoon-template-impl (the JXTemplateGenerator has been moved here)
<dependency>
<groupId>org.apache.cocoon</groupId>
<artifactId>cocoon-template-impl</artifactId>
<version>1.1.0</version>
</dependency>
Verify that your Maven repository contains the library. If not: install it.
2) In flowscript: have a function that will set some values and make a call to .SendPage()/.SendPageAndWait()
cocoon.sendPage("page/index",
{
username : "SomeName"
}
);
3) In sitemap.xmap: when generating XML-files, make sure they have type="jx"
<map:pipeline internal-only="true">
<map:match pattern="page/*">
<map:generate type="jx" src="xml/{1}.jx.xml"/>
<map:transform src="xslt/page.xslt"/>
<map:serialize type="html"/>
</map:match>
</map:pipeline>
4) In your .jx.xml-file: read values like this
<?xml version="1.0" encoding="UTF-8"?>
<jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
<valuesFromFlowscript>
<!-- Select values from flowscript -->
<username>${username}</username>
</valuesFromFlowscript>
</jx:template>
5) In your .xslt-file you can read the generated value like this
<xsl:value-of select="valuesFromFlowscript/username"/>