Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HashMap values in JSP?  RSS feed

 
koushi kumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Iam really stuck with this issue....
I have HashMap values like these below
[0.76,.0818] from DB
i want to display these values in each <TD> in jsp.
this is what am trying.......
setting HashMap values in arraylist in DAO class and iterating that arraylist into <TD> of Html table in jsp. am getting these two values in one <TD>
but i want to get the above two values in two different <TD>....
please suggest me with sample code how i can get these values in two different <TD> elements.
Appreciate your Help!!!
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you'd output a <td> start tag, then output the first value, then output a <td> end tag. Then you'd repeat for the second value. In general you'd iterate through the list, for each entry outputting a <td> start tag followed by the entry's value followed by a <td> end tag.

That should be similar to your existing code. If you can't change it to follow that recommendation, then post it here and ask about it.

By the way there's a general procedure for writing a JSP. Here it is:

  • Figure out what HTML you want.
  • Write your JSP to generate that HTML.


  • As you can see, this is a particular case of that procedure.
     
    koushi kumar
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Paul,

    Thanks for your replay.
    the Hashmap is returning two values and am setting those values in arraylist. when i try to iterate that arraylist its obvious that the list will return both values at the same time for each line. thats why when i try to do that in <td> those two values are being displayed in single TD
    here is the list of values i had to set in two <td>.
    output for Test java class:
    [0.79,0.8]
    [9,0.8]
    [0.69,0.98]
    here is my code:

    do i have to seperate these values before setting into arraylist?
    please suggest me.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 65824
    134
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    "kum kumar", please check your private messages for an important administrative matter.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!