• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to forward using jsp:forward

 
sanat meher
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

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 ]
 
Amit Ghorpade
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sanat meher:

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



JavaBean is not the place to put your Database kind of thing...

also use DAO class for DB . if your trying this program yourself then,please avoid scripting otherwise it depends on your PM(project manager )
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sanat meher
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know login is not properly validated with the database but again i m unable to find out where the exact error lies..
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi senant,




put e.printStackTrace() in your catch block. please debug clearly ..always put error message in your ctch block
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agreed with precious post:

Hi sanat,

Why don't you hard code the login validation process to just see whether
it is getting forwarded to concerned pages or not?
 
sanat meher
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

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

Regards,
Sanat
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two things:

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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic