This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I m designing a login page in which the userid and password will be submitted from login.jsp to the loginvalidate.jsp.Here i ll again use a javabean which connects to the database.First userid and password will be validated and then based on three types of user like manager,indexer,login person,the corresponding pages wiil be forwarded after satisfying the criteria which is written in the bean.but when i m inputing the correct id/pwd,the corresponding pages are not opening.rather it is forwarding to the retry.jsp.Can anybody please check out whre the error is: Following are the loginvalidate.jsp and loginbean.java
The code for javabean i.e loginbean is as follows
Regards, Sanat Kumar Meher
[ November 06, 2008: Message edited by: sanat meher ] [ November 06, 2008: Message edited by: sanat meher ]
Welcome to Javaranch sanat meher Firstly please make sure you use code tags while posting your code.Unformatted code is hard to read and results in less response for your post. Read this for more information. You can edit your current post to add code tags by clicking .
Is it something related to jsp forward or your page selection logic causes the default error page to be forwarded? I mean login id, and pwd not validated correctly, causing choose to forward to retry.jsp.
Joined: Nov 06, 2008
i know login is not properly validated with the database but again i m unable to find out where the exact error lies..
put e.printStackTrace() in your catch block. please debug clearly ..always put error message in your ctch block
Joined: Feb 28, 2007
Agreed with precious post:
Why don't you hard code the login validation process to just see whether it is getting forwarded to concerned pages or not?
Joined: Nov 06, 2008
I have changed the approach for login.now i m fetching role colunm for the matching userid and password.And then comaring value.This is working properly for correct id and password but when i m entering the wrong password,then it is unable to find the particular role which is null,so the nullpointer exception is shown instead of forwarding it to the retry.jsp Following are the code of the modified programs
Please find me way how to solve this nullpointer exception
1.) Avoid using the == operator for comparing strings. It may not return the results you're expecting. Use the String object's compare() method instead. If you're not sure why, ask about this in our Java In General (Beginner) forum. This is a common issue folks run into when starting out with Java.
2.) Check your server's logs to see exactly where the NullPointerException is being thrown. Once you know this, it should be easy for you to come up with a fix. If not, pointing us to the specific line number will make it easier (read: more likely) for us to help you.