• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using indexOf() in an if statement

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In one of my JSPs I am trying to compare a character to a string to see if there is an occurance, if so, I display an Input text box in html if not process the else for a different string as such--
<% if (" A&J".indexOf(lL200C.getMc__Commit__Until__Dt__A()) > 0) { %>
<INPUT TYPE="text" NAME="mc__Commit__Until__Dt_I" ID="mc__Commit__Until__Dt_I" SIZE="8" MAXLENGTH="8" VALUE="<%=lL200C.getMc__Commit__Until__Dt().trim() %>" >
<% } else %>
<% if ("HIQR".indexOf(lL200C.getMc__Commit__Until__Dt__A()) > 0) { %>
<INPUT TYPE="text" style="color: #ff0033;" NAME="mc__Commit__Until__Dt_I" ID="mc__Commit__Until__Dt_I" SIZE="8" MAXLENGTH="8" VALUE="<%=lL200C.getMc__Commit__Until__Dt().trim() %>" >
<% } else %>
<% if ("%_@'".indexOf(lL200C.getMc__Commit__Until__Dt__A()) > 0) { %>
<INPUT TYPE="text" style="color: #00ff66;background-color: #999999;" NAME="mc__Commit__Until__Dt_I" ID="mc__Commit__Until__Dt_I" SIZE="8" MAXLENGTH="8" VALUE="<%=lL200C.getMc__Commit__Until__Dt().trim() %>" READONLY>
<% } else %>
<% if ("-/01".indexOf(lL200C.getMc__Commit__Until__Dt__A()) > 0) { %>
<INPUT TYPE="text" style="background-color: #999999;" NAME="mc__Commit__Until__Dt_I" ID="mc__Commit__Until__Dt_I" SIZE="8" MAXLENGTH="8" VALUE="<%=lL200C.getMc__Commit__Until__Dt().trim() %>" READONLY>
<% } else %>
<% if ("YZ89".indexOf(lL200C.getMc__Commit__Until__Dt__A()) > 0) { %>
<INPUT TYPE="text" style="color: #ff0033;background-color: #999999;" NAME="mc__Commit__Until__Dt_I" ID="mc__Commit__Until__Dt_I" SIZE="8" MAXLENGTH="8" VALUE="<%=lL200C.getMc__Commit__Until__Dt().trim() %>" READONLY>
<% } else if ("<(*)".indexOf(lL200C.getMc__Commit__Until__Dt__A()) > 0) { %>
<INPUT TYPE="text" style="color:#00ff66;" NAME="mc__Commit__Until__Dt_I" ID="mc__Commit__Until__Dt_I" SIZE="8" MAXLENGTH="8" VALUE="<%=lL200C.getMc__Commit__Until__Dt().trim() %>" >
<% } %>



The problem is my if-else is not getting proceesed right and the control just goes to the last if....I am logging the value for
lL200C.getMc__Commit__Until__Dt__A()) which is ' '(space, but the first condition is not getting executed.
I am using Websphere test environment and the debugging is extremely slow...is there a better way to debug this code to see where my if is failing???
Thanks in advance!
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using the JSP execution monitor. You can also put breakpoints in the JSP code by clicking in the left area beside the code.
[This message has been edited by Shama Khan (edited October 10, 2001).]
 
Data Select
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah I tried using the monitor, but for some reason it is very slow and crashes my machine after about 3-4 pages of monitoring...is there some other JSP debuggin tool?

Thanks!
 
Did you miss me? Did you miss this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic