Last modified 3 years ago
To pass information between JSP and XSL you can use either the DOM directry - or you can pass parameters. To do this check out this sample jsp page:
<%@ page language="java" import="java.util.*,corinis.*,corinis.modules.*" %> <% Core core = new Core (pageContext); // init the core module Forum f = (Forum)core.getModule(Forum.class); core.addDom(f.getEntries()); core.addXslParameter("manage", String.valueOf(core.checkAuthority("FORUM_MANAGE"))); core.addXslParameter("yourParam", "cool")); out.print(core.parseDom("test.xsl", true)); %>
in the xsl you can then easily use these parameters (and quite a few default parameters)
<?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:param name="manage"/> <xsl:param name="username"/> <xsl:param name="yourParam" select="'ok'"/> <xsl:template match="/"> <h1>Manage the Forum: <xsl:value-of select="$manage"/></h1> <xsl:value-of select="$username"/> is <xsl:value-of select="$yourParam"/> </xsl:template> </xsl:stylesheet>
Default parameters include:
- username
- userid
- session - the session id
- date - the current date in a formatted way
