• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using indexOf() in an if statement

 
Data Select
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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!
 
Shama Khan
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!