File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How to create a drop down on pageload with data from a db Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to create a drop down on pageload with data from a db" Watch "How to create a drop down on pageload with data from a db" New topic
Author

How to create a drop down on pageload with data from a db

Joe Matt
Greenhorn

Joined: Feb 11, 2009
Posts: 4
Hello,
I am running a web application on tomcat 6.0 using jsp and mvc controllers.I have a jsp page which has a drop down list. This is the first/home page of the application. The drop down should be populated with data from a database when the page is first loaded. I was hoping to get the data as an object in the controller and use the jstl tags in the jsp page to create the drop down list
I am using mvc but no frameworks like spring or struts. Is there any methods similar to the refrencedata method in spring to prepopulate the form with data from backend? I am confused as how to trigger the controller to load the data from the db since there are no actions performed on the page when the page gets loaded first.

Thanks
-Joe
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

I'm not understanding the issue. If the page needs the data, the page controller fetches it from the model. Why does there need to be "page activity"?

Or, are you not using a page controller for your "home" page? If not, why not?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joe Matt
Greenhorn

Joined: Feb 11, 2009
Posts: 4
thank you. I wasn't passing the jsp through the controller and that was the problem.

-Joe
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create a drop down on pageload with data from a db
 
Similar Threads
Create new JSP page dynamically
spring web flow-tiles
Dynamic Drop Down Lists.
Drop down list value
How to retrieve data from database when ever select in drop down list?