Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8549695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:46:37+00:00 2026-06-11T13:46:37+00:00

this is my DB enquiry function public static List<UserPass> selectAllUser() { ConnectionPool pool =

  • 0

this is my DB enquiry function

        public static List<UserPass> selectAllUser() {
            ConnectionPool pool = ConnectionPool.getInstance();
            Connection connection = pool.getConnection();
            PreparedStatement ps = null;
            ResultSet rs = null;

            List<UserPass> usersPass = new ArrayList<UserPass>();

            String query = "select * from UserPass";
            try{
            ps = connection.prepareStatement(query);
            rs = ps.executeQuery();

            while(rs.next()){
            UserPass users = new UserPass();
            users.setUserName(rs.getString("user_name"));
            usersPass.add(users);

            }

            return usersPass;

and this is my UserPass object get function

   public ArrayList<UserPass> getusernames(){

   return usernames;
   }

my servlet dopost is simply this

    request.setAttribute("users", UserPassDb.selectAllUser());

    String forward = "/testpage.jsp";
    RequestDispatcher view = request.getRequestDispatcher(forward);
    view.forward(request, response);

and my display jsp page is

            <form action="TestServlet" method="post">
                <input type="submit">

            </form>

            <c:forEach var="user" items="${users}">

                <c:out value="${user.usernames}"/> 

            </c:forEach>

UserPass Class

            /*
            * To change this template, choose Tools | Templates
            * and open the template in the editor.
            */
            package business;

            import java.io.Serializable;
            import java.util.ArrayList;

            /**
            *
            * @author One
            */
            public class UserPass implements Serializable {


                public String username;
                public String password;

                public ArrayList<UserPass> usernames;


                public UserPass(){
                    this.username ="";
                    this.password ="";  
                    this.usernames = new ArrayList<UserPass>();
                }

                public void setUserName(String username) {
                    this.username = username;

                }
                public String getUserName(){

                    return username;
                }

                public ArrayList<UserPass> getusernames(){

                return usernames;
            }
                public void setusernames(ArrayList<UserPass> a){

                    this.usernames = a;
                }
            }

tried changing this it tells me property doesn’t exist when it does as far as i understand. am sure am wrong

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:46:39+00:00Added an answer on June 11, 2026 at 1:46 pm

    You have getusernames() which returns ArrayList and You did not mentioned setusernames(ArrayList<UserPass> ).

    But, If You want to display Usernames, In JSP, Change

    <c:forEach var="user" items="${users}">
    
            <c:out value="${user.username}"/> 
    
    </c:forEach>
    

    How this works:

    Here usersis the request attribute which is a List<UserPass>. Now,When you iterate it using forEach,You get UserPass in user for each row.

    Then user.username calls getUserName from UserPass bean.

    In your case user.usernames, It returns empty Arraylist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble with following linq2sql query: public IEnumerable List(IQueryable<Enquiry> enquiries, Supplier supplier) {
This works. $(document).ready(function(){ $(.items article).click(function(){ window.location=$(this).find(a).attr(href); return false; }); }); However , when the
This is my sample code: SPWeb web = SPContext.Current.Web SPList list = web.Lists[TestList]; try
My form action is set to a php file like this: <form name=addstudent action=includes/data.php?act=enquiry
Struggling with this one. I have set up a basic email/enquiry form for a
How would you add a target=_self function onto the buttons in this actionscript (as3)
[Not:e user is asking this again at Development of railway enquiry system, how to
I have this markup one of my web pages, <div class=radio-spoof> <input type=radio name=enquiry
this is my first question in here, and I would like to ask if
This question is directly related to this SO question I posed about 15 minutes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.