• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inner if condition is turning out to be false

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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"
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4567
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49370
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell,

I am still using java6..Not sure what is the actual issue
 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem resolvedddd

But still I am not able to understand where i was going wrong
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic