Need help for create csv ?

Rose_Taylor
Rose_Taylor used Ask the Experts™
on
I want to create csv from collections of objects ?seachbean.java is latestseach query data.This data want to create csv file using another servlet class.

Now i have to pass to values to servlet class and create csv file.

I am looking help now.

searchbean.java

public Object[] search(String str1, String str2, String str3, String str4, String pageIndex) {
		String returnValue = "";
		lastResults = null;
		
		try {
			String query = getCasesQuery();
			String where = buildWhere(str1,str2, str3);
			String orderBy = buildOrderBy(str4);


			lastResults = DBUtil.getSQL( query + where + orderBy );
			lastResults = mapCustomerDetails( lastResults );
			
			
		} catch (Exception e) {
			//returnValue = "Warning : " + e.getMessage();
			e.printStackTrace();
			returnValue = null;
		}

		return lastResults;
	}

createcsv.java(servlet class)
------------------------------

protected void doGet(HttpServletRequest request,
        HttpServletResponse response,Object lastResults) throws ServletException, IOException {
        
            //Object obj=AjaxBean.getLastSearchResultsAsCSV();
            response.setContentType("text/csv");
            response.setHeader("Content-disposition", "attachment; filename=" + filename);
	    resultSetToCsv(rst, response.getWriter());

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        	 try {
 				con.close();
 			} catch (SQLException e) {
 				// TODO Auto-generated catch block
 				e.printStackTrace();
 			}
        }
}
        public static void resultSetToCsv(ResultSet rs, Writer out) {
        	try {
        	    final String LINEFEED = "\r\n";
        	    ResultSetMetaData metaData = rs.getMetaData();
        	    int numberOfColumns = metaData.getColumnCount();

        	    // Get the column names
        	    String sep = "";

        	    for (int column = 0; column < numberOfColumns; column++) {
        		out.write(sep);
        		out.write(metaData.getColumnLabel(column + 1));
        		sep = ",";
        	    }

        	    out.write(LINEFEED);

        	    // Get all rows.
        	    while (rs.next()) {
        		sep = "";

        		for (int i = 1; i <= numberOfColumns; i++) {
        		    out.write(sep);
        		    out.write(""+rs.getObject(i));
        		    sep = ",";
        		}

        		out.write(LINEFEED);
        	    }
        	} catch (Exception e) {
        	    e.printStackTrace();
        	}
            }

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010

Commented:
Store previous search result somewhere, e.g. in a variable or session context, then output the data to request out stream in the servlet.

Author

Commented:
Yes, stored the search results in searchbean.java(return latestResults).This is a Object array in the search method.public Object[] search(...) Here stored in variable, and no session here.

Now i want to pass the latestResults to createcsv.java for create csv.How to pass the data to  resultSetToCsv(rst, response.getWriter());

Top Expert 2010

Commented:
Your SearchBean does not actually store the last search result anywhere, it only provides a method that returns the latest result given some parameters.

Either you invoke this method from the servlet, passing the necessary parameters to it, or you do actually store this result in a place accessible from the servlet. It can be one or another context, member variable, static variable, a map, associating users with latest searches - whatever your logic dictates.
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Author

Commented:
servlet class for create csv when hits the download button call the servlet file for download data csv file.But latest search result in another java class, so i need to bring the data to servlet class for create csv.

This is my idea, if you have any suggestions please give me.
Top Expert 2010

Commented:
As an example:

add a static variable to your searchbean and have it updated by your search method, then in the servlet read this variable and generate output.

Author

Commented:
Could you give the sample code, please......

Author

Commented:
I have code for export database to csv.This can able to export data to csv.

Now i need to export data which latestResults from search result.So i want to pass the values insteadof resultset.



protected void doGet(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
        String connectionURL = "------";
        String url = request.getParameter("WEB_URL");
        Statement stmt = null;
        Connection con = null;

        try {
            String filename = "SearchCases.csv";
            Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
            con = DriverManager.getConnection(connectionURL, "*****", "*******");
            stmt = con.createStatement();

            String qry = "select * from user_managecase";
           
            stmt.setMaxRows(20);
            
            ResultSet rst = stmt.executeQuery(qry);
            response.setContentType("text/csv");
            response.setHeader("Content-disposition", "attachment; filename=" + filename);
	    resultSetToCsv(rst, response.getWriter());

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        	 try {
 				con.close();
 			} catch (SQLException e) {
 				// TODO Auto-generated catch block
 				e.printStackTrace();
 			}
        }
}
        public static void resultSetToCsv(ResultSet rs, Writer out) {
        	try {
        	    final String LINEFEED = "\r\n";
        	    ResultSetMetaData metaData = rs.getMetaData();
        	    int numberOfColumns = metaData.getColumnCount();

        	    // Get the column names
        	    String sep = "";

        	    for (int column = 0; column < numberOfColumns; column++) {
        		out.write(sep);
        		out.write(metaData.getColumnLabel(column + 1));
        		sep = ",";
        	    }

        	    out.write(LINEFEED);

        	    // Get all rows.
        	    while (rs.next()) {
        		sep = "";

        		for (int i = 1; i <= numberOfColumns; i++) {
        		    out.write(sep);
        		    out.write(""+rs.getObject(i));
        		    sep = ",";
        		}

        		out.write(LINEFEED);
        	    }
        	} catch (Exception e) {
        	    e.printStackTrace();
        	}
            }

Open in new window

Looks like you could do it with one statement with the JDBC api.  Form the link:
http://www.java-tips.org/other-api-tips/jdbc/how-to-export-data-from-database-to-csv-file.html

           stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                    ResultSet.CONCUR_UPDATABLE);
           //For comma separated file
            query = "SELECT id,text,price into OUTFILE  '"+filename+
                    "' FIELDS TERMINATED BY ',' FROM testtable t";
            stmt.executeQuery(query);
Top Expert 2010
Commented:
class Searchbean {
...
public static Object[] lastResult;
...
 public Object[] search(String str1, String str2, String str3, String str4, String pageIndex) {
            String returnValue = "";
            lastResults = null;
...
lastResult = lastResults;
      return lastResults;


 }

public static Object[] getLastResult() {   return lastResult;}

in your servlet:

doGet(...) {
  ...
Object[] lastResult = SearchBean.getLastResult();
.. // do your work
}
Top Expert 2016

Commented:
Do we assume that SearchBean is returning one row only

Author

Commented:
Could you give me code for  download csv use of Object[] ..
Top Expert 2016

Commented:
Is that one row only?

Author

Commented:
No , search bean return more than one records.
Top Expert 2016

Commented:
>>No , search bean return more than one records.

So if it's a one dimensional array, how do you know how many rows and columns it contains?

Author

Commented:
Yes it is one dimentional array.But it returning more than one records.

Now, i need to create csv use of Object[].

I hope CEHJ remember did that below code.Now i want to create download data from Object[] data.Please help me.

Object[] lastResult = AjaxBean.getLastResult();
            
            response.setContentType("text/csv");
            response.setHeader("Content-disposition", "attachment; filename=" + filename);
	    resultSetToCsv(lastResult, response.getWriter());

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        	 try {
 				con.close();
 			} catch (SQLException e) {
 				// TODO Auto-generated catch block
 				e.printStackTrace();
 			}
        }
}
        public static void resultSetToCsv(Object[] lstrlt, Writer out) {
        	try {
        	    final String LINEFEED = "\r\n";
        	    ResultSetMetaData metaData = rs.getMetaData();
        	    int numberOfColumns = metaData.getColumnCount();

        	    // Get the column names
        	    String sep = "";

        	    for (int column = 0; column < numberOfColumns; column++) {
        		out.write(sep);
        		out.write(metaData.getColumnLabel(column + 1));
        		sep = ",";
        	    }

        	    out.write(LINEFEED);

        	    // Get all rows.
        	    while (rs.next()) {
        		sep = "";

        		for (int i = 1; i <= numberOfColumns; i++) {
        		    out.write(sep);
        		    out.write(""+rs.getObject(i));
        		    sep = ",";
        		}

        		out.write(LINEFEED);
        	    }
        	} catch (Exception e) {
        	    e.printStackTrace();
        	}
            }

Open in new window

Top Expert 2016

Commented:
>>Yes it is one dimentional array.But it returning more than one records.

Yes, you said that, but you didn't answer my last question about it...

Author

Commented:
I agree, not able to find coloumns and rows.So that i have hard coded the columns names.

and i used Object[] the rows only to display the number records..



public Object[] mapCustomerDetails(Object[] objs) throws SQLException { //, ParseException{
		String labels[] = {	"NUMBER", "TYPE", "DATE", "STATUS", 
							"CHANGE", "CODE", "SR_SUB_STAT_ID", "LAST_NAME", 
							"FST_NAME", "SSN", "BIRTH_DT", "STATE", "ROW_ID"
						};
		for(int i = 0; i < objs.length; i++ )
		{
			String obj[] = (String[])objs[i];

			Map<String, Serializable> map = new HashMap<String, Serializable>();
			for( int j=0; j < labels.length; j++) {
//				if ( (j == 2) || (j == 4) || (j == 10) ) {
//					map.put(labels[j], df.parse(obj[j]));
//				} else {
					map.put(labels[j], 	obj[j]);
//				}
			}
			
			map.put("FULL_NAME", 	obj[8] + " " + obj[7]);

			objs[i] = map;
		} 
		return objs;

Open in new window

Author

Commented:
CEHJ are you make sense ?

Author

Commented:
I didn't get any reply from you guys...Please any reply me...
Top Expert 2016
Commented:
Try the following:
    public void mapsToCsv(Object[] maps, Writer out) {
	final String LINEFEED = "\r\n";
	String[] labels = {
	    "NUMBER", "TYPE", "DATE", "STATUS", "CHANGE", "CODE",
	    "SR_SUB_STAT_ID", "LAST_NAME", "FST_NAME", "SSN", "BIRTH_DT",
	    "STATE", "ROW_ID"
	};
	// Get the column names
	String sep = "";

	for (int column = 0; column < labels.length; column++) {
	    out.write(sep);
	    out.write(labels[i]);
	    sep = ",";
	}
	out.write(LINEFEED);
	for(int i = 0;i < maps.length;i++) {	
	    Map<String, String> map = (Map<String, String>)maps[i];
	    sep = "";
	    for(int j = 0;j < labels.length;j++) {	
		String val = map.get(labels[i]);
		out.write(sep);
		out.write(val);
		sep = ",";
	    }
	    out.write(LINEFEED);
	}
    }

Open in new window

Top Expert 2010

Commented:
Your [clarified] question was ".How to pass the data to  resultSetToCsv(rst, response.getWriter());"

As an example, I suggested using a static variable to store results in and even provided some code.

The question is answered.

Author

Commented:
I am getting empty file.

SearchBean.java
----------------------
public static Object[] lastResults;

public Object[] search(String str1, String str2, String str3, String str4, String pageIndex) {
        String returnValue = "";
        lastResults = null;
       
        try {
            String query = getCasesQuery();
            String where = buildWhere(str1,str2, str3);
            String orderBy = buildOrderBy(str4);


            lastResults = DBUtil.getSQL( query + where + orderBy );
            lastResults = mapCustomerDetails( lastResults );
           
        } catch (Exception e) {
            //returnValue = "Warning : " + e.getMessage();
            e.printStackTrace();
            returnValue = null;
        }

        return lastResults;
    }
   
    public static Object[] getLastResult() {
          return lastResults;
        }


Createcsv.java
--------------------

protected void doGet(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
    try {
        String filename = "SearchCases.csv";
            Object[] lastResult = AjaxBean.getLastResult();
           
            response.setContentType("text/csv");
            response.setHeader("Content-disposition", "attachment; filename=" + filename);
        mapsToCsv(lastResult, response.getWriter());

        } catch (Exception e) {
            e.printStackTrace();
        }
}
public void mapsToCsv(Object[] maps, Writer out) {
    final String LINEFEED = "\r\n";
    try{
    String[] labels = {
        "NUMBER", "TYPE", "DATE", "STATUS", "CHANGE", "CODE",
        "SR_SUB_STAT_ID", "LAST_NAME", "FST_NAME", "SSN", "BIRTH_DT",
        "STATE", "ROW_ID"
    };
    // Get the column names
    String sep = "";

    for (int column = 0; column < labels.length; column++) {
        out.write(sep);
        out.write(labels[column]);
        sep = ",";
    }
    out.write(LINEFEED);
    for(int i = 0;i < maps.length;i++) {    
        Map<String, String> map = (Map<String, String>)maps[i];
        sep = "";
        for(int j = 0;j < labels.length;j++) {    
        String val = map.get(labels[i]);
        out.write(sep);
        out.write(val);
        sep = ",";
        }
        out.write(LINEFEED);
    }
    }catch(Exception e)
    {
        e.printStackTrace();
    }
    }


Top Expert 2016

Commented:
>>Object[] lastResult = AjaxBean.getLastResult();

Include some debugging print statements after that to see what you've got. Of course, you will have had to have called search in order to fill the array in the first place

Author

Commented:
In console getting nullpointer exception.
Top Expert 2016

Commented:
Please post the exception and the code you just tried

Author

Commented:
Object[] lastResult = AjaxBean.getLastResult();
            System.out.println("lastresult"+lastResult);

I am getting line like this..

lastresult[Ljava.lang.Object;@13d9211

Author

Commented:
lastresult[Ljava.lang.Object;@13d9211
java.lang.NullPointerException
    at org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:171)
    at com.talenthouse.managecases.struts.action.CsvAction.mapsToCsv(CsvAction.java:91)
    at com.talenthouse.managecases.struts.action.CsvAction.doGet(CsvAction.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)


Top Expert 2016

Commented:
That's fine.

I'm about to disappear for the day, so let's try to get it sorted out quickly. What do these print?


System.out.println(lastResult.length);

System.out.println(lastResult[0].getClass());

Open in new window

Top Expert 2016

Commented:
Oh and instead of

>>
 out.write(sep);
 out.write(val);
>>

try
out.write(sep);
out.write("" + val);

Open in new window

Author

Commented:
20
class java.util.HashMap



java.lang.NullPointerException
    at org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:171)
    at com.talenthouse.managecases.struts.action.CsvAction.mapsToCsv(CsvAction.java:94)
    at com.talenthouse.managecases.struts.action.CsvAction.doGet(CsvAction.java:65)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)
120
2class java.util.HashMap
java.lang.NullPointerException
    at org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:171)
    at com.talenthouse.managecases.struts.action.CsvAction.mapsToCsv(CsvAction.java:94)
    at com.talenthouse.managecases.struts.action.CsvAction.doGet(CsvAction.java:65)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)


Author

Commented:
I am getting null values in xl sheet.

search.csv

Author

Commented:
java.lang.ArrayIndexOutOfBoundsException: 13
    at com.talenthouse.managecases.struts.action.CsvAction.mapsToCsv(CsvAction.java:92)
    at com.talenthouse.managecases.struts.action.CsvAction.doGet(CsvAction.java:65)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)
java.lang.ArrayIndexOutOfBoundsException: 13
    at com.talenthouse.managecases.struts.action.CsvAction.mapsToCsv(CsvAction.java:92)
    at com.talenthouse.managecases.struts.action.CsvAction.doGet(CsvAction.java:65)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)


Top Expert 2016

Commented:
Better have a look into that array. Could you please post the results of
for(int i = 0;i < lastResult.length;i++) {
	System.out.println("" + lastResult[i]);
}

Open in new window

Author

Commented:
{STATE=TS, FULL_NAME=Reginald Sass, SOC_SECURITY_NUM=115607170, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/04/2010, REASON_CODE=null, LAST_NAME=Sass, CREATED_DATE=05/04/2010, BIRTH_DT=01/291964, CASE_NUMBER=1-31705556, ROW_ID=1-IR3G7, FST_NAME=Reginald}
{STATE=TS, FULL_NAME=Robert Allen-Morris, SOC_SECURITY_NUM=452769383, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/04/2010, REASON_CODE=null, LAST_NAME=Allen-Morris, CREATED_DATE=05/04/2010, BIRTH_DT=02/221947, CASE_NUMBER=1-31705905, ROW_ID=1-IR3G7, FST_NAME=Robert}
{STATE=TS, FULL_NAME=Diane Schleuder, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/06/2010, REASON_CODE=null, LAST_NAME=Schleuder, CREATED_DATE=05/06/2010, BIRTH_DT=06/261969, CASE_NUMBER=1-31800852, ROW_ID=1-IR3G7, FST_NAME=Diane}
{STATE=TS, FULL_NAME=John Tesauro, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/03/2010, REASON_CODE=null, LAST_NAME=Tesauro, CREATED_DATE=05/03/2010, BIRTH_DT=02/081951, CASE_NUMBER=1-31636160, ROW_ID=1-IR3G7, FST_NAME=John}
{STATE=TS, FULL_NAME=Raymond Scott, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/06/2010, REASON_CODE=null, LAST_NAME=Scott, CREATED_DATE=05/04/2010, BIRTH_DT=03/121968, CASE_NUMBER=1-31709134, ROW_ID=1-IR3G7, FST_NAME=Raymond}
{STATE=TS, FULL_NAME=Teresa Willett, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/04/2010, REASON_CODE=null, LAST_NAME=Willett, CREATED_DATE=05/04/2010, BIRTH_DT=01/011954, CASE_NUMBER=1-31709480, ROW_ID=1-IR3G7, FST_NAME=Teresa}
{STATE=TS, FULL_NAME=Dinnill Thomas, SOC_SECURITY_NUM=384-40-3227, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/06/2010, REASON_CODE=null, LAST_NAME=Thomas, CREATED_DATE=05/06/2010, BIRTH_DT=10/241940, CASE_NUMBER=1-31809842, ROW_ID=1-IR3G7, FST_NAME=Dinnill}
{STATE=TS, FULL_NAME=Melissa Cales, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/03/2010, REASON_CODE=null, LAST_NAME=Cales, CREATED_DATE=05/03/2010, BIRTH_DT=06/101973, CASE_NUMBER=1-31639283, ROW_ID=1-IR3G7, FST_NAME=Melissa}
{STATE=TS, FULL_NAME=Mary Gibson, SOC_SECURITY_NUM=292385567, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/03/2010, REASON_CODE=null, LAST_NAME=Gibson, CREATED_DATE=05/03/2010, BIRTH_DT=06/211940, CASE_NUMBER=1-31642077, ROW_ID=1-IR3G7, FST_NAME=Mary}
{STATE=TS, FULL_NAME=Arman Arahan, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/04/2010, REASON_CODE=null, LAST_NAME=Arahan, CREATED_DATE=05/04/2010, BIRTH_DT=07/291967, CASE_NUMBER=1-31714584, ROW_ID=1-IR3G7, FST_NAME=Arman}
{STATE=TS, FULL_NAME=Ann Maynard, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/06/2010, REASON_CODE=null, LAST_NAME=Maynard, CREATED_DATE=05/06/2010, BIRTH_DT=03/191951, CASE_NUMBER=1-31811570, ROW_ID=1-IR3G7, FST_NAME=Ann}
{STATE=TS, FULL_NAME=Hardy Morris, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/03/2010, REASON_CODE=null, LAST_NAME=Morris, CREATED_DATE=05/03/2010, BIRTH_DT=04/241958, CASE_NUMBER=1-31644649, ROW_ID=1-IR3G7, FST_NAME=Hardy}
{STATE=TS, FULL_NAME=Michael Taylor, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/06/2010, REASON_CODE=null, LAST_NAME=Taylor, CREATED_DATE=05/06/2010, BIRTH_DT=04/111952, CASE_NUMBER=1-31815044, ROW_ID=1-IR3G7, FST_NAME=Michael}
{STATE=TS, FULL_NAME=William Brackett, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/06/2010, REASON_CODE=null, LAST_NAME=Brackett, CREATED_DATE=05/06/2010, BIRTH_DT=03/021941, CASE_NUMBER=1-31815322, ROW_ID=1-IR3G7, FST_NAME=William}
{STATE=TS, FULL_NAME=Susan Cottrell, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/03/2010, REASON_CODE=null, LAST_NAME=Cottrell, CREATED_DATE=05/03/2010, BIRTH_DT=01/181955, CASE_NUMBER=1-31648272, ROW_ID=1-IR3G7, FST_NAME=Susan}
{STATE=TS, FULL_NAME=Jason Prior, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/03/2010, REASON_CODE=null, LAST_NAME=Prior, CREATED_DATE=05/03/2010, BIRTH_DT=11/261986, CASE_NUMBER=1-31648344, ROW_ID=1-IR3G7, FST_NAME=Jason}
{STATE=TS, FULL_NAME=Gary Legg, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/03/2010, REASON_CODE=null, LAST_NAME=Legg, CREATED_DATE=05/03/2010, BIRTH_DT=10/301971, CASE_NUMBER=1-31648438, ROW_ID=1-IR3G7, FST_NAME=Gary}
{STATE=TS, FULL_NAME=JD Hood, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/03/2010, REASON_CODE=null, LAST_NAME=Hood, CREATED_DATE=05/03/2010, BIRTH_DT=04/121962, CASE_NUMBER=1-31650898, ROW_ID=1-IR3G7, FST_NAME=JD}
{STATE=TS, FULL_NAME=Michael Taylor, SOC_SECURITY_NUM=999999999, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/05/2010, REASON_CODE=null, LAST_NAME=Taylor, CREATED_DATE=05/05/2010, BIRTH_DT=04/111952, CASE_NUMBER=1-31740453, ROW_ID=1-IR3G7, FST_NAME=Michael}
{STATE=TS, FULL_NAME=Gregory Brosek, SOC_SECURITY_NUM=243511975, SR_SUB_STAT_ID=Opted In, STATUS=Pending, CASE_TYPE=Adherence, STATUS_CHANGE=05/05/2010, REASON_CODE=null, LAST_NAME=Brosek, CREATED_DATE=05/05/2010, BIRTH_DT=05/211974, CASE_NUMBER=1-31740766, ROW_ID=1-IR3G7, FST_NAME=Gregory}
java.lang.ArrayIndexOutOfBoundsException: 13
    at com.talenthouse.managecases.struts.action.CsvAction.mapsToCsv(CsvAction.java:95)
    at com.talenthouse.managecases.struts.action.CsvAction.doGet(CsvAction.java:68)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)


Top Expert 2016

Commented:
Have to continue tomorrow unfortunately.

The labels in your array only partially correspond to the column names in your results

Author

Commented:
I am getting restults.But displaying rows.I need coloumns format.

Author

Commented:
It is working Great.Thank you very your time

Author

Commented:
Excellent
Top Expert 2016

Commented:
:)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial