Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP throwing null pointer exception the first time I run it

 
Anil Karamchandan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am facing a unique problem in JSP, I am running the below code as a webtab in one of my applications, i.e inside my application I have a provision to build in custom jsp pages and then to embed them inside an application, when i save my jsp and for the first time try to run it, it throws me a null pointer exception and logs me out of the system, then the next time I login and try to browse the same jsp it works fine..

Can any one let me know y..

 
Anil Karamchandan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have on purpose kept the div hidden since, I am getting the password from a webservice and supplying that password to the form, during that time, I do not want the user to see the form. The form should eb invisible to the user and all this should happen in the backend.

Regards,
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the stack trace.

Out of wild curiosity, why is the password pre-filled ?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And why is it pre-filled with what appears to be the result of a login process?
 
Anil Karamchandan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason why it is prefilled, is that, I dont want the user to login to that application, the login should happen on its own with one loginid and a one time password received from the java class (result).

thus the value of the password is obtained from the method.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why have a login page at all then?
 
Anil Karamchandan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the submit form, the action attribute sends the request to the other webpage, which needs to be seen inside my application .
The user clicks on the main page, the webservice is called, one time password is returned, this password is passed to the password field in the login page, and on auto submit the action attributes loads the other page on the same window.

I mean this is what i thought, any other views are most welcome... do you have one please
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. If you know the user name and password already, cant you authenticate the user yourself instead of waiting for him/her to press the login button ?
 
Marco Bartolini
Greenhorn
Posts: 9
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo sharma

I don't see the utility of the autologin if there is no user registration behind!
You can use the JSESSIONID to track the user session without giving him a fake name/password. Login features were created to manage restriction and protect access to data/resources, in your case i don't see the utility.
Maybe you have to reconsider your design

Btw at line 12 you create an object



but i don't see where you use the directive tag <%@ page import="com.example.foo.OneTimeLogin1" %> to import the class/package to see it and use it.
In the end, in my hopinion, it is better if you write a costum tag instead of use a scriptelts tag!

Scriptlets tag are the dark side of the force

 
Anil Karamchandan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Bala wrote:Yes. If you know the user name and password already, cant you authenticate the user yourself instead of waiting for him/her to press the login button ?


I just know the username, the password is a One time password obtained on every request. I talke this password, pass it to the form and autosubmit it..
 
Anil Karamchandan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marco Bartolini wrote:Hallo sharma

I don't see the utility of the autologin if there is no user registration behind!
You can use the JSESSIONID to track the user session without giving him a fake name/password. Login features were created to manage restriction and protect access to data/resources, in your case i don't see the utility.
Maybe you have to reconsider your design

Btw at line 12 you create an object



but i don't see where you use the directive tag <%@ page import="com.example.foo.OneTimeLogin1" %> to import the class/package to see it and use it.
In the end, in my hopinion, it is better if you write a costum tag instead of use a scriptelts tag!

Scriptlets tag are the dark side of the force



As i had mentioned earlier, my application provides this functionality to write jsp pages inside my application. All the classes and jsp are stored in the default package. It does an auto import
 
Anil Karamchandan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the whole point is, Why it is failing for the first time and then on the second run I am able to run it ??
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok. Is the one time password the same the first and second time ?

Debug onetimelogin.loginEmployee(); to find out why it fails the first time
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic