Link to home
Start Free TrialLog in
Avatar of princehyderabad

asked on

JSP causing JS to error


Just a wired error: NullPointerException

JSP page:

function main()
function okay()
 <% System.out.print("................"); %>
 return true;

Works fine. But when I add this code it shows me error:

function okay()
 <% System.out.print("................");
              //  Calling Stored Procedure
               CallableStatement cs2 = conn.prepareCall("{call abc(?) }");
               cs2.setString(1, userID);

 return true;

PS: All variable is define and I'm getting all valid values

Avatar of suprapto45
Flag of Singapore image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think that this is related to

If you use
<%@ page import = "" %>
Connection conn = null;

Make sure that you have set the conn from the Utils class that you used.
Avatar of jaggernat

first of all, trying to access database values using a scriplet from javascript code is a very bad idea.
javascript should be exclusively used for front-end operations and NOT backend. all your java code including database connectivity should be in a java class and when you submit your jsp, you make a call to that java class and perform all the databse operations in it.
Null pointer means it is returning empty or it does not have any thing in it and that is why you are getting that error

you had a very similar problem here.