how can I populate notifications in dropdown in JSP

Here is the code. When I click the dropdown icon, it is empty. I want it to be loaded as soon as the page loads

ArrayList<Notifications> notifications = (ArrayList<Notifications>) session.getAttribute("notif");


  <ul class="nav navbar-nav navbar-right">

                <li class="dropdown" data-toggle="tooltip" data-placement="bottom" title="Friend Requests">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-user"></i>
                    </a>


                    <ul class="dropdown-menu" role="menu">

                        <%
                            for(int i=0; i<notifications .size(); i++){
                        %>
                        <li>
                            <a href="#"><%= notifications .get(i).getSender() %></a>
                        </li>

                        <% } %>

                    </ul>

                </li>
            </ul>


Source: jsp

Leave a Reply