java - fetching records from database and displaying on struts webpage -


my query how fetch records database table , display on struts webpage. have pasted code below. when run code didn't error table not displayed though table contains many records. googled it, couldn't find answer. so's similar solution didn't me.. 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 {             class.forname("com.microsoft.sqlserver.jdbc.sqlserverdriver");             connection con = drivermanager.getconnection("jdbc:sqlserver://192.168.100.25:1433;databasename=db_h2h;user=sa;password=123");             preparedstatement ps = con.preparestatement("select * reporttracking.dbo.file_master");             resultset rs = ps.executequery();             while (rs.next()) {                 splitconfig sc = new splitconfig();                 sc.setfile_id(rs.getstring(1));                 sc.setcategory(rs.getstring(2));                 list.add(sc);              }             con.close();         } catch (exception e) {             system.out.println(e.getmessage());         }         return "success";     }  } 

//jsp page

<%@taglib prefix="s" uri="/struts-tags" %> <!doctype html> <html>     <head>         <meta http-equiv="content-type" content="text/html; charset=utf-8">         <title>jsp page</title>     </head>     <body>         <jsp:include page="header.jsp"/>         <jsp:include page="menu.jsp"/>         <h3>all records:</h3>           <s:iterator  value="list">               <fieldset>                   <s:property value="file_id"/><br/>                   <s:property value="category"/><br/>                </fieldset>           </s:iterator>           <jsp:include page="footer.jsp"/>     </body> </html> 

edit: //struts.xml

<!doctype struts public "-//apache software foundation//dtd struts configuration 2.0//en" "http://struts.apache.org/dtds/struts-2.0.dtd">  <struts>      <package name="subin" namespace="" extends="struts-default">          <action name="login" class="example.showloginaction">             <result name="success">/index.jsp</result>         </action>          <action name="pass" class="example.showpassaction">             <result name="success">/changepass.jsp</result>         </action>          <action name="config" class="example.showconfigaction">             <result name="success">/fileconfig.jsp</result>         </action>          <action name="splitcon" class="example.showsplitaction">             <result name="success">/filesplit.jsp</result>         </action>           <action name="dashboard" class="example.showdashboardaction">             <result name="success">/dashboard.jsp</result>         </action>          <action name="verify" class="example.loginaction">             <result name="success">/dash.jsp</result>             <result name="fail">/fail.jsp</result>         </action>          <action name="changep" class="example.passaction">             <result name="success">/dash.jsp</result>                         <result name="fail">/fail.jsp</result>         </action>          <action name="filecon">             <result name="success">/fileconfig.jsp</result>             <result name="fail">/fileconfig.jsp</result>         </action>       </package>    </struts> 

//web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">     <filter>         <filter-name>struts2</filter-name>         <filter-class>org.apache.struts2.dispatcher.filterdispatcher</filter-class>     </filter>     <filter-mapping>         <filter-name>struts2</filter-name>         <url-pattern>/*</url-pattern>     </filter-mapping>     <session-config>         <session-timeout>             30         </session-timeout>     </session-config>     <welcome-file-list>         <welcome-file>index.jsp</welcome-file>     </welcome-file-list> </web-app> 

i wrote different class name splitcon action... instead of showsplitaction, class should splitconfigaction...


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -