• 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

Updating DB automatically !

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
I have a program where I'm displaying a set of names in the form of a drop-down list using HTML on the browser. At present there are few names, but in future will add more to database. Now, my problem is, even the new names should get added to the drop down list automatically, without updating the HTML. How can I do this? How can the data be fetched directly from the database and at the same time be displayed in the drop down list?

Am using JSPs and servlets as back-end to update the database and display. Is there any way out for this or should one hard code to get the data displayed on the drop-down list?

 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swapna Gouri Kalanidhi wrote:Hi All
At present there are few names, but in future will add more to database. Now, my problem is, even the new names should get added to the drop down list automatically, without updating the HTML.



AJAX, Have you used it ? If not, AJAX will solve problem, without hard coding any database values in HTML !!
Just on onLoad () function of HTML page, call AJAX and it will populate the drop-down list.

Just search dependent dropdowns + AJAX
 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sagar
Thanks for the quick reply ! I haven't used Ajax till date and have no idea about Ajax. I'm a newbie to Java technologies. Instead of Ajax, is there any other way I can populate the data? I mean, is it not possible using JSPs or servlets or JSTL or such technologies? Because my entire project is on MVC architecture. And am almost reaching the deadline, so I cannot afford to learn a new technology at this point of time and apply.

Any suggestions would be much appreciated. Thanks again for your quick response !
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Ajax" is nothing more than a buzzword indicating an use technique. The actual languages involved are just plain Javascript, HTML DOM and XML, which existed more than 10 years each. On the server side you can do anything to your taste. If it is a Java EE environment, you can use a simple servlet for example.

To start, I can recommend this simple tutorial: http://www.w3schools.com/Ajax/Default.Asp

The actual Ajax solution which you´re looking for here is "Ajax poll". Let the webpage poll the server at certain intervals for updates. If there is any, then just update the dropdown using JS+DOM.
 
reply
    Bookmark Topic Watch Topic
  • New Topic