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 undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

I think that this is related to https://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21991629.html

If you use
<%@ page import = "com.abc.Utils" %>
Connection conn = null;

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

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.

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck