• Post Reply Bookmark Topic Watch Topic
  • New Topic

How Can I Populate Notifications In Dropdown In JSP  RSS feed

 
Mehmood Memon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i am clicking on dropdown menu, it shows me an empty list. I want it to be filled with records from the arraylist. please help !!!

<% 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="Notifications">
<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>
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36453
459
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mehmood,
Welcome to CodeRanch!

I'm guessing when you run that, it gives you an empty list. Have you confirmed that notifications is not empty?

Also, can you look at the generated HTML (view source) in your browser and see what is output there? (and post it).

Finally, take a look at JSTL. Using scriptlets in JSPs is considered old fashioned and you'll want to learn the modern way of making a JSP.
 
Mehmood Memon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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">



</ul>


this is the output in view page source
 
Mehmood Memon
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey i got it. My arraylist was empty because of a mistake in column name.
Thanks man !!
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36453
459
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome. I'm glad you got it working.

I'm female, so I"ll change "thanks man" to "thanks ma'am" in my mind :).
 
Mehmood Memon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haha my bad, I wish i could edit it :/
well thanks Ma'am :)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!