Forums

Home » Liferay Portal » English » Liferay Legacy

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Henrik Bentel
Escaped JSP scriptlet strings
August 5, 2005 11:53 AM
Answer

Henrik Bentel

Rank: Junior Member

Posts: 45

Join Date: June 5, 2005

Recent Posts

Hi<br /><br />I was wondering the reason for escaping strings inside JSP scriplets or tags.<br /><br />For example, this exist in one of the JSPs:<br /><i>&lt;c:if test=&quot;&lt;%= (refreshRate &#33;= null) &amp;&amp; (&#33;refreshRate.equals(&#092;&quot;0&#092;&quot;)) %&gt;&quot;&gt;</i><br />where the nested string&#39;s quotes are escaped. Very... unusual.<br /><br />Has this been fixed or changed in 3.5?<br /><br />thx,<br />Henrik
trav trav
Escaped JSP scriptlet strings
August 7, 2005 9:00 PM
Answer

trav trav

Rank: Junior Member

Posts: 63

Join Date: July 24, 2005

Recent Posts

Hi<br /><br />I was wondering the reason for escaping strings inside JSP scriplets or tags.<br /><br />For example, this exist in one of the JSPs:<br /><i>&lt;c:if test=&quot;&lt;%= (refreshRate &#33;= null) &amp;&amp; (&#33;refreshRate.equals(&#092;&quot;0&#092;&quot;)) %&gt;&quot;&gt;</i><br />where the nested string&#39;s quotes are escaped. Very... unusual.<br /><br />Has this been fixed or changed in 3.5?<br /><br />thx,<br />Henrik<br />

<br />
<br />My guess would be that it needs to escape the strings to parse the tag properly, it&#39;s a bit ugly, I would have thought that there would be a better way of doing that particular piece, isn&#39;t there a greater than tag and a present(not null) tag? I know there is in the struts library and it seems like a fairly standard thing.<br />If you&#39;re going to use nasty scriptlet stuff like that why not just write a full blown scriptlet if?<br />
1<%if&#40;&#40;refreshRate&#33;=null&#41;&amp;&amp;&#40;&#33;refreshRate.equals&#40;&#34;0&#34;&#41;&#41;{%>
2html/jsp code here
3<%}%>
Brett Randall
Escaped JSP scriptlet strings
August 8, 2005 5:51 AM
Answer

Brett Randall

Rank: Liferay Legend

Posts: 1254

Join Date: August 17, 2004

Recent Posts

Of course you are free to check the HEAD or 3.5.0 code in CVS yourself ... <!--emo&emoticon--><img src='@theme_images_path@/emotions/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo--><br /><br />But since I have checked already, this has become:<br /><br />
1
2<c&#58;if test=&#39;<%= &#40;refreshRate &#33;= null&#41; &amp;&amp; &#40;&#33;refreshRate.equals&#40;&#34;0&#34;&#41;&#41; %>&#39;>
<br /><br />... so yes, the escaping has gone. Not sure on your concern with the original escaping ... looks JSP spec compliant to me. The CVS commit-log suggests that some of the commercial servlet containers couldn&#39;t cope with it.
Henrik Bentel
Escaped JSP scriptlet strings
August 8, 2005 9:35 AM
Answer

Henrik Bentel

Rank: Junior Member

Posts: 45

Join Date: June 5, 2005

Recent Posts

yepp, checked the CVS. it has changed. sweeet&#33;<br /><br />I searched the spec and couldn&#39;t find it refer to if escaped quotes are acceptable or not. Not that the java specs are the easiest to search. I&#39;ve always seen just the alternating single and double quote usage before. Never this.<br />The Weblogic appc(precompiler) couldn&#39;t cope with the escaped quotes, so the generated java files contained syntax error. <br /><br />even better, now I have a valid reason to upgrade. <br /><br />
Brett Randall
Escaped JSP scriptlet strings
August 8, 2005 2:13 PM
Answer

Brett Randall

Rank: Liferay Legend

Posts: 1254

Join Date: August 17, 2004

Recent Posts

For your interest, the JSP 2.0 spec talks about quoting in section JSP.1.6:<br /><br />
JSP 2.0 Spec section JSP.1.6<br />&lt;snip/&gt;<br />Quoting in Attributes<br />&lt;snip/&gt;<br />A “ is quoted as &#092;”. This is required within a double quote-delimited attribute<br />value.<br />&lt;snip/&gt;<br />The entities &amp;apos; and &amp;quot; are available to describe single and double<br />quotes.<br />
<br /><br />... but it goes on to describe the valid double-quotes inside single-quoted attributes example.