Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JSP Combobox and Java Class

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranches,
I have developed an application with the combination of html, JSP and Servlet...
i have created a jsp file with 3 combo box....
for first 2 combo boxes am passing value from database..
but for the third combo i need to pass array values from a java file...

the code is as follows:


i need to pass these values to :



How to do that? please i need help.
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ambika Nagalakshmi wrote:i have created a jsp file with 3 combo box


Actually, you haven't. Part of professional programming is using the proper terminology. There is no such thing as a "combobox" on the web. Please see HtmlHasNoComboBox for more information.

How to do that?


Set the array data as a scoped value in the request in the controller. Then in the JSP, use the EL and the JSTL <c:forEach> tag to iterate over the array and create the option elements.
 
Maya Naga
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear.. actually it was my mistake to mention as combo box..
Am new to JSP and Servlet..
Please can you give me some example...
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set the array data as a scoped value in the request in the controller.
or
or

Then in the JSP, use the EL and the JSTL <c:forEach> tag to iterate over the array and create the option elements.

Just my thoughts !!!
<EDIT 1:image wasn't displayed properly>
 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But just remember that Java code and Java scriptlets should never be used in a JSP. Ever. That's a a very bad practice that has been discredited for over 8 years now.
 
I'm gonna teach you a lesson! Start by looking at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic