Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
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
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Object Relational Mapping
How to Get Data Into Comobox From Databse Using Hibernate in JSP Page?
Shashank Acharya
Greenhorn
Posts: 21
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Any One Solve this Problem.
This is what i do with my page of get value from database into combo box.
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.util.*,org.hibernate.*,util.*,entity.*"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Online Attendance Main Page</title> <script src="ajax.js" type="text/javascript"></script> </head> <body> <% try { SessionFactory sf = HibernateUtil.getSessionFactory(); Session s = sf.openSession(); Transaction tx = s.beginTransaction(); Second se = new Second(); String hql = "select area from hibernatedb.second"; Query q = s.createQuery(hql); ArrayList li = (ArrayList) q.list(); Iterator ie = li.iterator(); %> <center> Area:- <% while (ie.hasNext()) { se = (Second) ie.next(); %> <select> <option> <%se.getArea();%> </option> </select> <%} } catch (HibernateException he) { he.printStackTrace(); }%> </center> </body> </html>
The result of this code is empty combo box.
Please help in this problem.
Thanks in advance.
Girish Wakure
Greenhorn
Posts: 28
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
<center> Area:- <% while (ie.hasNext()) { se = (Second) ie.next(); %> <select> <option> <%se.getArea();%> </option> </select> <%} } catch (HibernateException he) { he.printStackTrace(); }%> </center>
change above code to
<center> Area:- <select> <% while (ie.hasNext()) { se = (Second) ie.next(); %> <option> <%se.getArea();%> </option> <%} %> </select> <% } catch (HibernateException he) { he.printStackTrace(); }%> </center>
It will generate as many options as rows in the table
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Submit dynamically created form with jQuery
If-Else In JSTL
Getting null while trying to get value of Multiple list
struts2 + Tiles, why pages shrink in top center ?
document.forms[0].submit(); throws Invalid Argument in IE
More...