• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

Issue with If statement in java servlet

"If statement" does not works in my java servlet.


first textMessage was printed out with variable values.
The textMessage="in if(tckStat.equals(A) "; never been accessed


Please advise, code below. Entire code in attached file.
if((tckStat.equals("A"))&&(tckCls.equals("Y"))){
           
                     code.....
}
 
//then tried:
 
textMessage = " tckStat- " + tckStat + " tckCls - " + tckCls + " tckRsl - "+ tckRsl;
 
    if(tckStat.equals("A")){
                         textMessage="in if(tckStat.equals(A) ";
                         if(tckCls.equals("Y")){
                  code...
         }
}

Open in new window

SegmenCode.txt
0
Vadim2004
Asked:
Vadim2004
  • 2
  • 2
1 Solution
 
gaston_acevedoCommented:
are you sure that Upper is the correct case?
use equalsIgnoreCase when compare and try.
Anyway, you can post the result the select statement?

0
 
Vadim2004Author Commented:
Yes, its upper case.
result of select statement:
"select ticket_status_code, ticket_closed_yn, ticket_resolved_yn from ticket where ticket_num ='" + ticketNo + "'"

ticket_status_code      ticket_closed_yn      ticket_resolved_yn
            A                          Y                              Y
0
 
objectsCommented:
try trimming it

    if(tckStat.trim().equals("A")){

0
 
gaston_acevedoCommented:
Just for test, can you plz reverse the if question?

if((tckStat!=null && "A".equalsIgnoreCase(tckStat.toString()) && (tckCls!=null && "Y".equalsIgnoreCase(tckCls.toString()))){

0
 
Vadim2004Author Commented:
Gaston, just tested
          if(((tckStat!=null && "A".equalsIgnoreCase(tckStat.toString()) && (tckCls!=null && "Y".equalsIgnoreCase(tckCls.toString()))){ .....}

does not work, previouse  suggestions was accepted - if(tckStat.trim().equals("A")){....}
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now