aspose file tools*
The moose likes JSP and the fly likes JSP throwing null pointer exception the first time I run it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP throwing null pointer exception the first time I run it" Watch "JSP throwing null pointer exception the first time I run it" New topic
Author

JSP throwing null pointer exception the first time I run it

Anil Karamchandan
Ranch Hand

Joined: Sep 12, 2009
Posts: 47
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

Joined: Sep 12, 2009
Posts: 47
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

Joined: Feb 24, 2006
Posts: 6657
    
    5

Post the stack trace.

Out of wild curiosity, why is the password pre-filled ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And why is it pre-filled with what appears to be the result of a login process?
Anil Karamchandan
Ranch Hand

Joined: Sep 12, 2009
Posts: 47
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

Joined: Sep 29, 2008
Posts: 12617

Why have a login page at all then?
Anil Karamchandan
Ranch Hand

Joined: Sep 12, 2009
Posts: 47
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

Joined: Feb 24, 2006
Posts: 6657
    
    5

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

Joined: Dec 14, 2009
Posts: 8
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


System.out.print("Hello World! SCJP 5 79% - SCWCD 5 86%");
Anil Karamchandan
Ranch Hand

Joined: Sep 12, 2009
Posts: 47
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

Joined: Sep 12, 2009
Posts: 47
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

Joined: Sep 12, 2009
Posts: 47
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

Joined: Feb 24, 2006
Posts: 6657
    
    5

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP throwing null pointer exception the first time I run it
 
Similar Threads
Please solve my "java.lang.NullPointerException" error
Problem with encoding type in the browser
problem with jsp for reset() method
Doubts in jsp
Login JSP if condition and redirecting issue