• Post Reply Bookmark Topic Watch Topic
  • New Topic

null pointer exception

 
etika ahuja
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi




my insertion of the fields is taking place in the table but its not forwarding to home.jsp instead it is giving me null pointer exception

what could be the reason
 
Swastik Dey
Rancher
Posts: 1683
7
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you directly execute home.jsp?
 
etika ahuja
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it displays the home.jsp page
 
etika ahuja
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
firstly the user need to login then only then home.jsp page will be displayed..
 
Swastik Dey
Rancher
Posts: 1683
7
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's fine, only thing I wanted to know if you execute that page directly, whether it gets displayed without any exception or not. If you get any exception, means the problem is in home.jsp.
 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason for a null pointer exception?
Probably one of the parameters you are retrieving is not present, and is thus null.

The null pointer exception would be caused by any of the checks in your if statement calling the param.length() method.
If the parameter is null, that will cause the exception.

Solution: check for (param != null) && (!"".equals(param.trim())

Checks for
- null
- empty strings/spaces

This sort of java code is best done in a servlet/bean rather than a JSP.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!