aspose file tools*
The moose likes JSP and the fly likes calling a method of a java class from jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "calling a method of a java class from jsp" Watch "calling a method of a java class from jsp" New topic
Author

calling a method of a java class from jsp

Nishad Banodkar
Greenhorn

Joined: Jun 08, 2011
Posts: 5
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
Ranch Hand

Joined: Aug 06, 2010
Posts: 359
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.


Oracle Certified Professional: Java SE 6 Programmer
Oracle Certified Expert: Java EE 6 Web Component Developer
Oracle Certified Expert: Java EE 6 Enterprise JavaBeans Developer
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60056
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
wood burning stoves
 
subject: calling a method of a java class from jsp
 
Similar Threads
Problem in Retrieving Data
stuck on assignment. any help
Strange Enum
Collection on jsp
Problem submitting html:select value