• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

bean:write tag

 
aamchi mumbai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i have hashmap which contain following values

HashMap hm = new HashMap();
hm.put("id", "111");
hm.put("name", "Java");
hh.put("date",new java.util.Date());

request.setAttribute("data", hm);

in jsp

<bean:write name="data" property="id"/> <!-- Working Fine -->
<bean:write name="data" property="name"/> <!-- Working Fine -->
<bean:write name="data" property="date"/> <!-- THIS IS NOT WORKING -->

i am stuck here.

Thanks in Advance
 
Junilu Lacar
Bartender
Posts: 7598
53
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In what way is it not working? Is it throwing an exception or is it just not displaying in the format that you want?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you are trying to display a date, you need to tell Struts how to format the date. Here is how:

  • In your ApplicationResources.properties file, create a key such as date.format=MM/dd/yy (this can be any valid Java date format)
  • In your <bean:write tag, specify formatKey="date.format"

  •  
    aamchi mumbai
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Junilu Lacar:
    In what way is it not working? Is it throwing an exception or is it just not displaying in the format that you want?


    its not throwing any exception but it is not displaying that value.
     
    aamchi mumbai
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks it is working now
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic