Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Populate listbox from sql

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I populate a listbox from sql? Thanks.
 
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just read data from database and for each record put it html list box syntax as values.
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at the JSTL (Java Standard Tag Library) SQL & Core Taglibs. You'll want to use the <sql:query> tag to query your database, then use the <c:forEach> tag to iterate through the row set, placing the value in your list. You'll also need to create your datasource and JDBC connection in your web application. All this is not something that can be explained in a few sentences. I'd recommend taking a look at one of the many books available on JSTL and/or JavaServer Pages. JavaServer Pages 2nd Edition (for JSP 1.2 & JSLT 1.0) by Hans Bergsten (published by O'Reilly) has a nice chapter on the subject of database access using JSP. The third edition (on JSP 2.0 & JSTL 1.1) was recently published also.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,

But if this question was asked in the first place, I am not sure if author is familiar with JSTL and learning JSTL just to populate the list is not worth it. Of course it's good for other projects. Just my opinion.
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Alex Kravets:
Mark,

But if this question was asked in the first place, I am not sure if author is familiar with JSTL and learning JSTL just to populate the list is not worth it. Of course it's good for other projects. Just my opinion.



Some valid points Alex. I guess I was just in auto response mode and replied with what I felt was the best way of doing it, failing to stop and consider the author's current skill set. My bad.

(BTW, your reply was not present when I started to type my reply. I would not want you to think I was attempting to imply your reply was incomplete or inaccurate).
 
Sheriff
Posts: 67592
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But there's nothing wrong with nudging them in the right direction either. "Current skillset" should never be a static set.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course not. But I see all these technologies as a way to simlify readability/usability of your code and not learning the workings behind it.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,

 
In the renaissance, how big were the dinosaurs? Did you have tiny ads?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic