• 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
  • 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

Dynamic selection of <option> in a JSP

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

I have a JSP with html <select><option></option></select>. On initial load, a specific entry is selected with the <option> attribute of 'selected'. Based on a servlet result, can the selected <option> be changed - back and forth multiple times ? And if so, how ?



Cheers,
Oogway.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you generate the HTML -- which is what you are doing with that JSP -- you can flag one of the options with the "selected" flag using the <c:if> element of JSTL.

However I'm not sure that was the question you were asking. There was something about "initial load", which sounds like what happens in a browser. That's irrelevant to JSP, as the JSP is just generating the HTML for the browser. And you asked whether the selected option could be changed, which also doesn't make sense -- who or what would be changing it?
 
Oogway Tan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

Explaining it a bit further, the .jsp is -


xyz.jsp.inc is


abc.jsp.inc is


pqr.jsp.inc is


This page gets called forward / backward as part of Struts Actions and also by way of a 'Refresh' button (Struts Action).

When the conditions are correct, the second <option> gets selected. But when the conditions are incorrect, the second <option> is still displayed, though I want the first <option> to be displayed.


Oogway.
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic