Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSP tag attribute cannot be set more than once?

Tags:

jsp

jsp-tags

I have some old JSP files with tags such as

<mytag:editbox name="SEL_1" param="onclick='clickit();" param="size='4'" />.

These JSP runs very well in Websphere 5.0. When I move it into Websphere 8.0, something is wrong. The java source compiled by JSP like this:

editbox.setName("SEL_1");
editbox.setParam("size='4'");  //replaced by the last one
editbox.setParam("size='4'");

The last [attributes] overwrites those before it. I also test the JSP in Websphere 6.0 and Tomcat. WAS6 is same as 8.0, and Tomcat says:

org.apache.jasper.JasperException: /index.jsp (line: 17, column: 20) Attribute qualified names must be unique within an element

The attribute of tag can't be set more than once.

Is this the requirement of JSP 2.0+ specification? (I think the JSP container in WAS5.0 is JSP 1.2 .)

I can merge the two param attribute into one to correct the problem, but how to get the correct result without changing the JSP source?

like image 593
culy Avatar asked May 16 '12 13:05

culy


1 Answers

Having multiple attributes with the same name was never supported by the JSP spec. If it worked on Websphere 5 then that would have depended on proprietary behaviour permissible by that server version, and not by any others. I take it the tag class does something like adding the values to a collection, or some such.

You'll need to refactor the tag to be spec-compliant, either by using a delimited string, or using nested tags.

like image 140
skaffman Avatar answered Nov 15 '22 11:11

skaffman