NewBee Developer NewBee Developer - 19 days ago 6
Java Question

fetching records from database and displaying on struts webpage

My query is how to fetch records from a database table and display it on struts webpage. I have pasted my code below. When I run this code I didn't get any error but the table is not displayed even though the table contains many records. I googled it, but couldn't find the answer. Even the SO's similar solution didn't help me.. Thanks in advance.

//POJO Class

package example;

public class SplitConfig {

private String file_id;
private String category;

public String getFile_id() {
return file_id;

public void setFile_id(String file_id) {
this.file_id = file_id;

public String getCategory() {
return category;

public void setCategory(String category) {
this.category = category;


//Action Class

package example;

import com.opensymphony.xwork2.ActionSupport;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

public class SplitConfigAction extends ActionSupport {

private ArrayList<SplitConfig> list = new ArrayList<SplitConfig>();

public ArrayList<SplitConfig> getList() {
return list;

public void setList(ArrayList<SplitConfig> list) {
this.list = list;

public SplitConfigAction() {

public String execute() throws Exception {
try {
Connection con = DriverManager.getConnection("jdbc:sqlserver://;databaseName=db_h2h;user=sa;password=123");
PreparedStatement ps = con.prepareStatement("select * from reporttracking.dbo.FILE_MASTER");
ResultSet rs = ps.executeQuery();
while ( {
SplitConfig sc = new SplitConfig();

} catch (Exception e) {
return "success";


//JSP Page

<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<jsp:include page="header.jsp"/>
<jsp:include page="menu.jsp"/>
<h3>All Records:</h3>
<s:iterator value="list">

<s:property value="file_id"/><br/>
<s:property value="category"/><br/>

<jsp:include page="footer.jsp"/>


"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"


<package name="subin" namespace="" extends="struts-default">

<action name="login" class="example.ShowLoginAction">
<result name="success">/index.jsp</result>

<action name="pass" class="example.ShowPassAction">
<result name="success">/changepass.jsp</result>

<action name="config" class="example.ShowConfigAction">
<result name="success">/fileconfig.jsp</result>

<action name="splitcon" class="example.ShowSplitAction">
<result name="success">/filesplit.jsp</result>

<action name="dashboard" class="example.ShowDashboardAction">
<result name="success">/dashboard.jsp</result>

<action name="verify" class="example.LoginAction">
<result name="success">/dash.jsp</result>
<result name="fail">/fail.jsp</result>

<action name="changep" class="example.PassAction">
<result name="success">/dash.jsp</result>
<result name="fail">/fail.jsp</result>

<action name="filecon">
<result name="success">/fileconfig.jsp</result>
<result name="fail">/fileconfig.jsp</result>




<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="" xmlns:xsi="" xsi:schemaLocation="">


I wrote a different class name for splitcon action... Instead of ShowSplitAction, the class should be SplitConfigAction...