Passing parameters to XSL using JSTL?

Posted on 2008-10-22
Last Modified: 2013-11-24
I'm trying to pass a couple parameters back to XSL using the JSTL tag library, but the values are not getting passed.  My code is attached.  

The page loads, but the two values are not being passed.  All I get is a page without any content that would have been filled in the for-each loop.

///// JSP code ////

<%@ taglib prefix="c" uri="" %>

<%@ taglib prefix="x" uri="" %>


	String pageStart = "1";

	String pageLimit = "10";


	if (request.getParameter("s") != null)


		pageStart = (String)request.getParameter("s");



	if (request.getParameter("l") != null)

		pageLimit = (String)request.getParameter("l");





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />




    <c:import url="test2.xml" var="xmldoc" />

    <c:import url="test2.xsl" var="xslt" />

    <x:transform xml="${xmldoc}" xslt="${xslt}">

    	<x:param name="pageLimit" value="1"/>

         <x:param name="pageStart" value="10"/>




////// XSL: /////////

<?xml version="1.0"?> 

<xsl:stylesheet version="1.0" xmlns:xsl="">

<xsl:output method="html" omit-xml-declaration="yes"/>

<xsl:strip-space elements="*"/>

	<xsl:template match="/">

      <xsl:param name="pageStart" />

      <xsl:param name="pageLimit" />

      <xsl:variable name="end" select="$pageStart + $pageLimit - 1"/>

  	  <xsl:variable name="docsort" select="Table/Row[position() &gt;= $pageStart and position() &lt;= $end]"/>







                <xsl:if test="$pageStart - $pageLimit &gt;= 1">

                    <a href="?s={$pageStart - $pageLimit}&amp;l={$pageLimit}">prev</a>



              <td align="right">

                <a href="?s={$pageStart + 1}&amp;l={$pageLimit}">next</a>



            <tr bgcolor="#CCCCCC">

              <th>Element 1</th>

              <th>Element 2</th>


            <xsl:for-each select="$docsort">


                    	<xsl:for-each select="Table/Row/Cell">

                      		<td><xsl:value-of select="element1"/></td>









//// XML FILE ////

<?xml version="1.0"?>









Open in new window

Question by:cacklebunny
  • 2
LVL 60

Accepted Solution

Geert Bormans earned 100 total points
ID: 22777024
The parameters are local to the template for match="/"
and should be global

 <?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
      <xsl:param name="pageStart" />
      <xsl:param name="pageLimit" />
      <xsl:template match="/">

should work

Author Closing Comment

ID: 31508760
Sure did, thanks!
LVL 60

Expert Comment

by:Geert Bormans
ID: 22781246

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface In the first article: A Better Website Login System ( I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now