i have a project that i am working on which is based on struts and hibernate and i have created a bean class which i am using to retrieve some data and i want to display the value in the JSP but it is rfeturning a null pointer exception i guessed the error is from the bean...but cant figure it out any hel will be appreciated.
Here is my code
in case what i am trying to achieve is not too clear what i want is to retrieve some data from database with resultset and display the content on JSP and i want to follow the structure of struts where jsp is only used for displaying
So... you're not actually trying to display a resultset in the JSP, rather the results of some calculations done on a resultset.
In Struts 2 data is usually exposed by creating an action property and displaying it via the <s:property> tag or JSP EL. Personally I'd just create an "amount" property and set it to the results of the calculations done in the bean.
Joined: Mar 06, 2009
i would really appreicate it if you would demonstrate it using a simple code to display the results of some calculations done on a resultset
I'm not really sure what you just said, but the configuration goes in the struts.xml configuration file inside a package definition. The class should be a fully-qualified Java class, wherever you implemented it.
the problem you have declared "int amount" as a local variable same variable you are returning .so that it returns like that.
instead of that declare "amount " variable starting of method ,assign to the variable and return the same variable amount
The OP asked about getting data back to the JSP, which is what I addressed. Without knowing anything more about the contents of the database the logic in getAmount() doesn't affect that part of the question--it's up to the OP to determine if the logic being used to generate the data is correct, which isn't really related to Struts itself.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: I NEED TO DISPLAY A RESULTSET IN A JSP CORE TAG