• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem using a taglib with rtexprvalue set to true with tomcat  RSS feed

 
Max Cok
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have to use a proprietary taglib (I could modify it if i need to) which use rtexprvalue set to true.

Until now, no problem. In fact, the problem occurs when i try to pass some arguments:

In my jsp, the taglib is called like

<mytaglib param="<%= MyClass.getValue(...) %>" />


where MyClass.getValue(...) is a method wich returns a string containing xml. To prevent some incorrect behaviour, xml characters and quotes are escaped into their html equivalents : < become &lt; , " become &quot;.

Let's take the example where MyClass.getValue() return the string "&lt; tag param1=&quot;abc&quot; /&gt;" (which basically correspond to <tag param1="abc" />).

I want escaped html characters remain inchanged. It is the case when i use an old version of wsad (version 5.1.1, which take about 90% of my memory and force me to go and take a coffee each time i want to run my appli) However, if i want to use tomcat, the behaviour is not the same and the application crash before calling the taglib code because the html characters are evaluated.

the error looks like (free traduction cause i use a localized version of tomcat, so error messages might be irrelevant) :

org.apache.jasper.JasperException: Unable to compile class for jsp
An error occurred at line :334 in jsp file :/WEB-INF/blablabla.jsp

_jspx_th_mytaglib_mytaglib_2.setParam("<tag param1="abc">")

So, what i want to do is to prevent tomcat (as wsad seem to handle it) escaping html characters when evaluating taglib parameter.

The jsp version i use is 1.1

Thanks.

[ August 23, 2006: Message edited by: Max Cok ]

[ August 23, 2006: Message edited by: Max Cok ]

[ August 23, 2006: Message edited by: Max Cok ]

[ August 23, 2006: Message edited by: Max Cok ]
[ August 23, 2006: Message edited by: Max Cok ]
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP1.1? That would be Tomcat3? Surely WSAD5.1 was JSP1.2?

The code generated makes it look like you are trying to set the attribute of a custom tag with another tag, which is invalid syntax.

The line of code you showed out of the created servlet
_jspx_th_mytaglib_mytaglib_2.setParam("<tag param1="abc">")
looks like it was created by the following line in a jsp:
<mytaglib param="<tag param1="abc" />" />

Just as a question, would the code run on Tomcat4 or 5 unchanged?
 
Max Cok
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the jsp code is created by a line that looks like this :

<mytaglib param='<%= "&lt;tag param1=&quot;" + MyClass.getValue() + "&quot; /&gt;" />' />

With wsad (jsp v 1.1, pretty old but those are the requirements on the appliction i work on), it works flawlessly, but with tomcat 5.0 (used with eclipse 3.2 + wtp), i couldn't have managed to make it work.
 
Max Cok
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may have found the origin of the problem; It's tomcat parser wich replace the ""e" by '"' (see org.apache.jasper.compiler.Parser.parseQuoted()).

As i didn't see in the tomcat code a flag wich would have allowed me to disable those replacements, guess to only way to go through this problem ( except of course getting another servlet web engine) is to modify and recompile tomcat...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!