Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

bean:write tag

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 17665
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks it is working now
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic