Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem calling servlet to build a list of data from a database and display a jsp page

 
Efekodo Kingsley
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please need help solving the problem of calling a servlet to build list of data from a database and display it on a jsp page.anytime i run my jsp code it gives me a runtime error.

my servlet code

my jsp code


error message

thanks for usual understanding
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


List data= (List)request.getAttribute("data");


One thing to suspect is the request.getAttribute("data") returns null . Is the request originated from servlet ? or you directly hit the jsp.
 
Vijitha Kumara
Bartender
Posts: 3914
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And, how you map the servlet in web.xml & access the servlet from the URL?
 
Efekodo Kingsley
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes,the request is originated from the servlet.am using netbean ide,i think the ide does the mapping for me.can some one help to find a solution. thanks
 
Vijitha Kumara
Bartender
Posts: 3914
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Efekodo Kingsley wrote:am using netbean ide,i think the ide does the mapping for me.can some one help to find a solution.


So, How do you deploy & invoke the servlet? Inside a web container? If so we need to see your web.xml mapping and URL used to invoke the servlet.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the servlet invoked at any way? Run a debugger or place sysouts at strategic locations printing the info or variables of interest.

Apart from the actual problem, you should not use scriptlets. Drop them all and use taglibs and EL. The JSTL's c:forEach tag is perfectly suitable for looping over a List.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic