• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unable to forward using jsp:forward

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 )
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic