This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes How to display  retrivied users from the Datase into Drop-down menu using servlet+JSP(JSTL) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to display  retrivied users from the Datase into Drop-down menu using servlet+JSP(JSTL)" Watch "How to display  retrivied users from the Datase into Drop-down menu using servlet+JSP(JSTL)" New topic
Author

How to display retrivied users from the Datase into Drop-down menu using servlet+JSP(JSTL)

Vas Miriyala
Ranch Hand

Joined: Sep 14, 2009
Posts: 114

Hi
Here what I am going to do is I want to display existign users in database in Drop-down menu, for this i have written class file to connect to database ,one more class file to perform database queries and one servlet for calling method which i have retrived an stored in arraList, and then i have written jsp(using JSTL) file to display the users in drop-down menu,but my JSP file is not showing any user and these are the code i have written
Database1.java

comboboxServlet.java


and finally user.jsp


guys please help me and thanks in advance
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
This problem is not the same as this other? http://www.coderanch.com/t/471351/JSP/java/JSTL-Servlet-beans

What problem do you have? What are you doing in line 39 in the Servlet? You are overwritting the ArrayList with the session element!
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
And this piece of code in jsp:


is very wrong, is not XML compliance, and the forEach is very strange, please look at the documentation for contructing a forEach, userREsult does not have any other reference in the code posted... please, clarify yourself before posting code
Vas Miriyala
Ranch Hand

Joined: Sep 14, 2009
Posts: 114

thanks for you reply,My porblem is JSP file is not showing users in the drop-dwon menu and in line 39 I am retriving arraylist object from the session object and correct me if i am wrong,I tried with commenting line 39 but same problem
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Look to this info for building EL elements:

http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html

You cannot access anything you want in your JSP, you have to access scoped attributes, declared variables or implicit objects
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
srinivas miriyala wrote:thanks for you reply,My porblem is JSP file is not showing users in the drop-dwon menu and in line 39 I am retriving arraylist object from the session object and correct me if i am wrong,I tried with commenting line 39 but same problem


But do you have that ArrayList in the Session? Have you set it before? Do you have your ArrayList in any scope to be retrieved by the JSP? You have to set it in the request or in session (better in request) as an attribute in the Servlet



then in your JSP you access it:



But please, first of all look at the documentation for creating JSPs with JSTL and EL.
Vas Miriyala
Ranch Hand

Joined: Sep 14, 2009
Posts: 114

well thanks for you help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display retrivied users from the Datase into Drop-down menu using servlet+JSP(JSTL)