Hi there
I have a small application (Java and JSP) that, amongst other things, displays a client's portfolio details - funds, stocks and cash, using WML as the markup language.
A client can have multiple portfolios. I am currently using hashtables to display the portfolio names, then the total value of the portfolio, then break the portfolio value down into separate totals for funds, stocks and cash.
I am having trouble with my second hashtable, which displays the total portfolio value. For a given portfolio id, there can be only one record in the database. The portfolio id is the primary key.
The results of the SQL SELECT statement (which works correctly as a straight database query) are placed into a ResultSet by a bean called PortfolioBean. The short form of this name in the code pasted below is simply 'portfolio'. The contents of the ResultSet are then placed into a hashtable called portfolio_breakdown_hashtable.
The JSP page calls a get method on a holding class called PortfolioBreakdown, which contains methods returning the elements of the hashtable.
When I run the JSP, the value returned for any of the amounts (stocks, funds or cash) is 0.0 If I call the method getPortfolioName, nothing at all appears on the screen (note: 'null' is NOT displayed). I am pretty confident that the hashtable does have elements in it, as otherwise I would not get the card titled "display" appear on screen. I have a feeling that the problem is that I have to use the Hashtable method nextElement, when in fact there is only one element in the hashtable - or am I wrong? Maybe my understanding of what constitutes an element is wrong? Please could you have a look at my code and advise. Maybe there is another approach altogether that I should be using? If possible, however, I would like to continue using hashtables.
Many thanks,
Clive.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
< relevant portion of JSP page>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++==
< relevant portion of PortfolioBean.java>
+++++++++++++++++++++++++++++++++++++++++++++
< PortfolioBreakdown.java>
(edited by Cindy to format code)
[This message has been edited by Cindy Glass (edited September 28, 2001).]