aspose file tools*
The moose likes JSP and the fly likes unable to forward using jsp:forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "unable to forward using jsp:forward" Watch "unable to forward using jsp:forward" New topic
Author

unable to forward using jsp:forward

sanat meher
Greenhorn

Joined: Nov 06, 2008
Posts: 18
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

Joined: Jun 06, 2007
Posts: 2716
    
    6

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 .


SCJP, SCWCD.
|Asking Good Questions|
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Feb 28, 2007
Posts: 1707
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.


cmbhatt
sanat meher
Greenhorn

Joined: Nov 06, 2008
Posts: 18
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

Joined: Jan 28, 2008
Posts: 5575

Hi senant,




put e.printStackTrace() in your catch block. please debug clearly ..always put error message in your ctch block
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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

Joined: Nov 06, 2008
Posts: 18
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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unable to forward using jsp:forward