Bookmark Topic Watch 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Question:

I am trying to generate the <html:option> tags in my action class and store it in action form to display on the screen. I am using html:select tag and my code looks like this.


When I set the value to the form variable fieldValue in the struts Action class to something like

I am not able to see the value in the select dropdown in the screen.



Answer:

The html:option tag, or for that matter, any Struts tag will work only if you place it directly in the JSP, not if you generate it through a scriptlet. To understand why it won't work to generate it in a scriptlet, let's review the JSP life cycle:


  • The JSP interpreter reads the JSP file, including any custom tags such as Struts tags and converts everything to Java source code
  • It then compiles it into a class file
  • It executes the code, rendering a response in plain HTML and sending it back to the browser.
  • It is only at this point that the scriptlet code you inserted gets executed. It is now too late in the cycle to insert any custom tags, since they've already been interpreted by this point.




  • Return to StrutsFaq
     
    He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
      Bookmark Topic Watch Topic
    • New Topic