Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling a method of a java class from jsp

 
Nishad Banodkar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i have a page called CollegeRegistration.jsp. in this page i am using one dropdown in which i need to get values from database.

i have called a method of that class using its object. This method returns an ArrayList.
i have done following coding
ArrayList universityName=CAPUtility.getUniversityNames();
getUniversityNames() method returns an arraylist which contains all values to be displayed in drop down.

when i run this page i get null pointer exception on for the above line....

please help me in same.a bit urgent...
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not much information to go on, but calling that line from your JSP (I'm assuming you're using scriptlets to do this?) sounds like an A-team style explosion waiting to happen.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The use of Java in JSPs has been discredited for almost 10 years now. Don't you think it's time to learn how to write JSP the correct way?

Fetch the database values in the controller and pass them to the JSP. It'll not only follow modern best practices, it will make it easier to debug such problems.

Please read this article for more information on properly structuring web applications.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic