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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis
  • Mark post as helpful
  • send pies
  • Report post to moderator

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.


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
    Put the moon back where you found it! We need it for tides and poetry and stuff. Like this tiny ad:
    how do I do my own kindle-like thing - without amazon
      Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!