aspose file tools*
The moose likes JDBC and the fly likes inner if condition is turning out to be false Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "inner if condition is turning out to be false" Watch "inner if condition is turning out to be false" New topic
Author

inner if condition is turning out to be false

Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1056



The first if statement I am able to get into but its not going within the second if statement, the user name and password is mapped with the type admin but still i am not getting the output "you are logged in as Admin"


http://www.lifesbizzare.blogspot.com || OCJP:81%
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

Vishal Hegde wrote:

if(rs.getString("type").trim().equals("admin"))
{


[/code]

The first if statement I am able to get into but its not going within the second if statement, the user name and password is mapped with the type admin but still i am not getting the output "you are logged in as Admin"


That's simple then - whatever rs.getString("type") returns isn't equal to "admin" (case-sensitive). Have you debugged or tried printing out what rs.getString("type") returns?

[My Blog] [JavaRanch Journal]
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1056

Yes I did i even checked with case sensitivity... its all fine its admin itself in the table but stilll not sure where i am getting wrong
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4467
    
    8

Vishal Hegde wrote:Yes I did i even checked with case sensitivity... its all fine its admin itself in the table but stilll not sure where i am getting wrong

Don't check in the table, check the actual value being returned by rs.getString("type").
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1056

Thanks a lot for your prompt response ...Really appreciate your kind support, the admin issue has been resolved now the issue is with the student login and the code i am tryin is as below



I am inputting user id and password mapped to the type student..but not sure where it is getting stuck in this case
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39869
    
  28
Are you using Java7? If so, consider using a switch-case structure instead of those else-ifs. Or consider creating a RequestDespatcher object, and retrieving it from a Map<String, RequestDespatcher>.
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1056

Hi Campbell,

I am still using java6..Not sure what is the actual issue
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1056

Is it because i am using RequestDispatcher twice I just removed requestDispatcher code and added simple

if the type is admin


if type is student


In this case the looping is working perfectly fine
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1056

Problem resolvedddd

But still I am not able to understand where i was going wrong
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inner if condition is turning out to be false