Results 1 to 4 of 4
- 02-09-2011, 12:08 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 3
- Rep Power
- 0
how to display data in a table format using jstl tag
hello friends,
i am having a problem in displaying the data in a table format using jstl forEach tag. i am using springs and retrieving data from a controller using model and view and storing it in an ArrayList. now i want to display it to the user using a jsp page. Please help.
- 02-09-2011, 12:38 PM #2
Java Code:<table> <c:forEach var="script" items="${scripts}" varStatus="varCounter"> <tr> <td>${script.name}</td> <td>${script.type}</td> </tr> </c:forEach> </table>Skype: petrarsentev
http://TrackStudio.com
- 02-09-2011, 01:13 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 3
- Rep Power
- 0
LoginFormController.java
public class LoginFormController extends SimpleFormController {
@Override
protected ModelAndView onSubmit(Object command) throws ServletException {
Statement stmt;
Connection connection;
ArrayList processName=new ArrayList();
ArrayList description=new ArrayList();
ArrayList parentId=new ArrayList();
ArrayList processType=new ArrayList();
try {
Class.forName("com.mysql.jdbc.Driver");
connection=DriverManager.getConnection("jdbc:mysql ://localhost:3306/emsdb","root","mysql");
stmt=connection.createStatement();
String data="select * from processt";
ResultSet resultSet=stmt.executeQuery(data);
while(resultSet.next()){
String row1=resultSet.getString("ProcessName");
processName.add(row1);
String row2=resultSet.getString("Description");
description.add(row2);
String row3=resultSet.getString("ParentId");
parentId.add(row3);
String row4=resultSet.getString("ProcessType");
processType.add(row4);
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ModelAndView modelAndView = new ModelAndView(getSuccessView());
modelAndView.addObject("name", processName);
modelAndView.addObject("description", description);
modelAndView.addObject("parentId", parentId);
modelAndView.addObject("processType", processType);
return modelAndView;
}
thanks for the reply petr
this is my controller class and i have created a view for it to show the values in table format....please modify this code.
success.jsp
<%@page import="java.util.ArrayList"%>
<%@ page session="false"%>
<%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="/spring" %>
<html>
<head>
<title>Success</title>
</head>
<body>
<table BORDER="1">
<tr>
<th>Name</th>
<th>Description</th>
<th>parent-Id</th>
<th>Process-Type</th>
</tr>
<core:forEach begin="1" end="5">
<tr>
<td><core:out value="${name}"/></td>
<td><core:out value="${description}"/></td>
<td><core:out value="${parentId}"/></td>
<td><core:out value="${processType}"/></td>
</tr>
</core:forEach>
</table>
<center>
<a href="login.html">Back</a>
</center>
</body>
</html>
- 02-09-2011, 01:26 PM #4
Member
- Join Date
- Feb 2011
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
populate html table using jstl
By niteangell21 in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 01-16-2011, 08:10 PM -
What is the different between Text format display on web browser and display on midle
By Basit781 in forum CLDC and MIDPReplies: 1Last Post: 05-31-2010, 08:46 AM -
populate an HTML table(jstl)
By Rajib27 in forum New To JavaReplies: 0Last Post: 03-15-2010, 09:54 AM -
Data formatting for the <display:table>
By yuchuang in forum Web FrameworksReplies: 3Last Post: 12-14-2007, 10:52 AM -
Is there any utility that reads TimeZone data and display it in Human readable format
By Santhosh in forum Advanced JavaReplies: 0Last Post: 11-06-2007, 02:20 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks