0

We have migrated the tomcat from version tomcat-5.5.15 to tomcat-7.0.62.

The below code works fine with the older verions of tomcat i.e tomcat-5.5.15

<%!
    private final String
            barredUserTextId = "lightBlue",
            barredUserTextClass = "smalli";
%>

<summary:table summary='userlist' rowTextId='<%= "black,${userStatusTextCode}==sd_user_status_barred?"+barredUserTextId %>' rowTextClass='<%= "small,${userStatusTextCode}==sd_user_status_barred?"+barredUserTextClass%>'>

But the same code doen not work with new version of tomcat. The part of code which has issue with new version(tomcat-7.0.62) of tomcat is

rowTextId='<%= "black,${userStatusTextCode}==sd_user_status_barred?"+barredUserTextId %>' 

rowTextClass='<%= "small,${userStatusTextCode}==sd_user_status_barred?"+barredUserTextClass%>'

The above line of code is not working for me.

I tried changing it like below , but none of it worked for me.

<summary:table summary='userlist' rowTextId="<%= {userStatusTextCode} eq \"sd_user_status_barred\"  ? \"lightBlue\" : \"black\"  %>" rowTextClass="${userStatusTextCode eq \"sd_user_status_barred\" ?  \"smalli\" : \"small\" }">

<summary:table summary='userlist' rowTextId='<%= ${userStatusTextCode} == "sd_user_status_barred" ? "black" : "lightBlue" %>' rowTextClass='<%= ${userStatusTextCode} == "sd_user_status_barred" ?  "smalli" : "small"  %>'>

<summary:table summary='userlist' rowTextId="<%= ${(userStatusTextCode == 'sd_user_status_barred') ? \"black\" : \"lightBlue\" %>" rowTextClass="<%= ${(userStatusTextCode} == 'sd_user_status_barred') ?  \"smalli\" : \"small\"  %>" >

<summary:table summary='userlist' rowTextId="${(userStatusTextCode == 'sd_user_status_barred') ? \"black\" : \"lightBlue\" }" rowTextClass="${(userStatusTextCode == 'sd_user_status_barred') ?  \"smalli\" : \"small\" }" >

<summary:table summary='userlist' rowTextId="${(userStatusTextCode == 'sd_user_status_barred') ? 'lightBlue' : 'black' }" rowTextClass="${(userStatusTextCode == 'sd_user_status_barred') ?  'smalli' : 'small' }" >

I have already referred the some links and tried it

Here are the referred links

How to write if else condition using ternary operator in jstl

http://www.javabeat.net/ternary-operator-in-jsp-2-0-expression-languageel/

Ternary operator in JSTL/EL

How to correctly write the expression so that it will work with tomcat 7.

Community
  • 1
  • 1
Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47
  • 1
    What is the exception or error you are facing in console ? – Suresh Atta Oct 01 '15 at 08:34
  • 1
    This is never intented to work like that. The application is apparently relying on an obscure Tomcat 5.x bug. Get rid of `<%=` and `%>` and retry with alone `${ ... }`. Moreover, didn't you notice that no one of the examples in the answers you found contained `<%= ... %>`? – BalusC Oct 01 '15 at 08:38
  • @BalusC : I will try and let you know... – Abhijit Bashetti Oct 01 '15 at 09:40
  • @sᴜʀᴇsʜᴀᴛᴛᴀ : Its not throwing any exception...but the css it not been applied to the rows of the table.. – Abhijit Bashetti Oct 01 '15 at 09:41
  • @BalusC : I modified the part as rowTextId="${(userStatusTextCode == 'sd_user_status_barred') ? \"lightBlue\" : \"black\" }" rowTextClass="${(userStatusTextCode == 'sd_user_status_barred') ? \"smalli\" : \"small\" }" ....but still the css for the rows are in black... – Abhijit Bashetti Oct 01 '15 at 11:10
  • Follow the examples. Do not use `\"`. Just use `'`. When still in vain, look in HTML output if it looks all right. – BalusC Oct 01 '15 at 11:12
  • @BalusC : corrected it...also checked the html output...but still the condition is not been evaluated...it still shows all the rows of the table in black color... – Abhijit Bashetti Oct 01 '15 at 11:39
  • You're being ambiguous. Do you mean that you still see `${ ... }` in unparsed form in the generated HTML output, or that you're seeing literal string `black` in place of `${ ... }`? – BalusC Oct 01 '15 at 11:50
  • I see literal black for all the rows...If the conditions is true its should be lightBlue for some of the rows...But the expression is not been evaluated... – Abhijit Bashetti Oct 01 '15 at 11:54

1 Answers1

0

We got the solution for this. We need to modify the Java code written for the custom tag created for this.

There is method doEndTag() which had the code

cellId = ((cellId == null) ? getTable().rowTextId() : cellId);

This code was returning the fixed cellId and was not changing. Sort of constant number.

Changed the code to

cellId = getTable().rowTextId();

And the issue resolved for us.

There was nothing wrong at the JSP side. It was correct as per syntax. The change was to be done at the JAVA side which was getting executed for the custom tag.

I hope this would be helpful for someone. Solution may not be helpful, but it may trigger a idea at least to check.

Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47