Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting null point exception Error

 
Mayank Adhikari
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Steps performed:

1. created a test2.jsp page where it display a list of players in a DROP-DOWN menu by querying database using JDBC.

2. User select a player from the above drop down list and click "SUBMIT" the player name which will get POST to a servlet "Playerprofile.java".

3. The Player name will be processed by Playerprofile.java and the player name will be returned back to the test2.jsp page.

4. using this player name(provided by Playerprofile.java in the above steps) in test2. jsp page to get the furthur stastics for the player by quering the database againg.


ISSUE: On Step 4 i am getting Null point exception ERROR.

Please find below my code.


test2.jsp>>>




*********************************************************

Playerprofile.java >>>>



 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure to UseCodeTags while posting your code, I have added them in the above post for you.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, no one writes that much scriptlet code in a JSP, you are defying the entire JSP purpose.
Did you see the stack trace to find out what part of the code is throwing the NPE?
Moreover the idea of submitting the entire JSP is not really good, do you want the DB code to go over again?
You need AJAX.
 
caleb momanyi
Ranch Hand
Posts: 43
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in addition to all that has been said. you should also try to use a debugger with break points in your code, you can find out what variable is null at the point of executive to throw the exception
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic