Mantis - Resin
Viewing Issue Advanced Details
852 minor always 01-10-06 08:48 01-10-06 15:44
ferg  
ferg  
urgent  
closed 3.0.17  
fixed  
none    
none 3.0.18  
0000852: jsp:include issue
(rep by Rudy D'Hauwe)

We have an issue with in Resin 3.0.17, here is an example
"index.jsp" page:

<%
String nextPage = "next.jsp?param1=value1";
String param2 = "value2";
String param3 = "value3";
%>

The next.jsp page prints the request parameters:

param1=<%= request.getParameter("param1"); %>
param2=<%= request.getParameter("param2"); %>
param3=<%= request.getParameter("param3"); %>

With Resin 3.0.17 this results in :

param1=value1?param2=value2
param2=null
param3=value3

The problem occurs when the page attribute of jsp:include is a runtime-attribute,
and contains a query.

I implemented a fix for this problem in com.caucho.jsp.java.JspInclude.java.

Original code:

public void generate(JspJavaWriter out)
throws Exception
{
boolean hasQuery = false;

if (_page == null)
throw error(L.l(" expects a `page' attribute. `page'
specifies the path to include."));


if (hasRuntimeAttribute(_page)) {
out.print("pageContext.include(");
out.print(getRuntimeAttribute(_page));
}
else {
String page = _page;

out.print("pageContext.include(");
out.print(generateParameterValue(String.class, _page));

if (_page.indexOf('?') >= 0)
hasQuery = true;
}

if (_params != null) {
generateIncludeParams(out, _params, hasQuery);
}

out.print(", " + _flush);

out.println(");");
}



Bug fix replacement for the generate method (not yet optimized for performance) :

public void generate(JspJavaWriter out)
throws Exception
{
boolean hasQuery = false;

if (_page == null)
throw error(L.l(" expects a `page' attribute. `page'
specifies the path to include."));

if (hasRuntimeAttribute(_page)) {

out.println("if (" + getRuntimeAttribute(_page) + ".indexOf('?')>=0) {");

out.print("pageContext.include(");
out.print(getRuntimeAttribute(_page));
if (_params != null) {
generateIncludeParams(out, _params, true);
}
out.print(", " + _flush);
out.println(");");

out.println("} else {");

out.print("pageContext.include(");
out.print(getRuntimeAttribute(_page));
if (_params != null) {
generateIncludeParams(out, _params, hasQuery);
}
out.print(", " + _flush);
out.println(");");

out.println("}");

}
else {
String page = _page;

out.print("pageContext.include(");
out.print(generateParameterValue(String.class, _page));

if (_page.indexOf('?') >= 0)
hasQuery = true;

if (_params != null) {
generateIncludeParams(out, _params, hasQuery);
}

out.print(", " + _flush);
out.println(");");
}
}

Notes
(0000667)
ferg   
01-10-06 15:44   
jsp/15lb, jsp/15m0