This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem to display table data in jsp using tags  RSS feed

 
Ratna Raju
Greenhorn
Posts: 3
Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends help me...
my jsp code is like this..


<table border="0" cellpadding="1">
<thead>
<tr>
<th>User Name</th>
<th>First Name</th>
<th>Last Name</th>
<th>Created Date</th>
<th>Email</th>
<th>Status</th>
</tr>
</thead>
<%
HttpSession ses=request.getSession();
ArrayList user=(ArrayList)ses.getAttribute("Userslist");
for(int i=0;i<user.size();i++)
{
Users u=(Users)user.get(i);
%>
<tr>
<td><%=u.getUsername()%></td>
<td><%=u.getFirstname() %></td>
<td><%=u.getLastname() %></td>
<td><%=u.getCreatedDate() %></td>
<td><%=u.getEmail() %></td>
<td><%=u.getStatus() %></td></tr>
<%}
%>
</table>

But i want write this code in tags (script less)
please help me

-Clarence
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start by reading JSTL page
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Some hints to get you started:

  • In the EL, you can just use the name of any scoped variable. So within and EL expression all you need to use is UsersList. (By convention, that should be usersList. In java, variable names start with lowercase.)
  • The JSTL's <c:forEach> tag would be used to iterate over the list.
  • To fetch a property, drop the 'get' and lowercsase the first letter. So you can get at the username property with ${u.username} and the createdDate property with ${u.createdDate}
  • If you need to make sure that the output is HTML-escaped (alweys a good idea for user-entered values), use the <c:out> tag.
  •  
    pravin venkat
    Greenhorn
    Posts: 20
     
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!