• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This problem is not the same as this other? https://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
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well thanks for you help
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic