This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring + JDBC + Servlet

tatiana erm
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to get a value in a form from the jsp, then pass to the servlet, and then store it to the DB using Spring and JDBC

I constantly get a NullPointer exception in a line
rd.addResult(r) of my servlet (this line is supposed to make an instance of ResultDaoImpl and add it to DB )
i cannot understant why

i think the problem is in the way i am using spring beans and manage creating objects, i ask the community for some code review


I have a JSP wich asks user to enter the expression paramenter

Here is a piece of a servlet:
It receives a Parameter from JSP (expression),
creates an object Result, sets the Result's value to "expression"
creates a jdbcTemplate
adds this

here is my ResultDaoImpl class:

my spring-config.xml:

My DAO Implementation class:

Best Regards, Tania.
Mark Spritzler
Posts: 17276
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I don't see anywhere you actually using Spring in your application. Especially when you have a line in your Servlet that creates your ResultDao.

new ResultDaoImpl();

Anyway, how are you starting up Spring. How are you getting your beans in your Servlet.

You say you get the NPE at


well if it is truly at that line means that rd is null.

But maybe the stack trace shows a line further in.

Please post your stack trace. Also have you tried running the debugger and seeing exaclty what is null.

I agree. Here's the link:
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic