Web tier: servlets, JSP, Web frameworks: JSP - CSV to EXCEL - Junior :-)

  1. JSP - CSV to EXCEL - Junior :-) (2 messages)

    Hi All: REAL junior at this stuff and looking for a little help. :) I have a built hyperlink that calls an action in my jsp. Here's the code that builds the hyperlink: &fileName="> I have the action as such: package com.allstream.registry.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import com.allstream.registry.beans.OrderFileManagementDetailForm; /** * @version 1.0 * @author */ public class OrderFileManagementDetailAction extends BaseAction { private String logID = null; private String fileName = null; private String fileContents = null; private String lanID = null; public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors errors = new ActionErrors(); ActionForward forward = new ActionForward(); HttpSession session = request.getSession(); OrderFileManagementDetailForm orderFileManagementDetailForm = (OrderFileManagementDetailForm) form; //The below 2 setting are just for testing purposes. Eventually the values will have //to be set somewhere in this code. //orderFileManagementDetailForm.setLogID("10"); //orderFileManagementDetailForm.setFileName("DansCSVFile.csv"); //first check the session to see if the lan id is present lanID = (String) session.getAttribute("lanID"); if (lanID == null) { lanID = request.getHeader("HTTP_OBLIX_UID"); System.out.println("the lan id stored in the header is: " + lanID); if (lanID == null){ lanID = "WI10014"; errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("errors.order.list","The lan id was not supplied, please contact systems support")); } session.setAttribute("lanID", lanID); } //TODO... Put in the call here to get the data to display in the excel browser. try { logID = orderFileManagementDetailForm.getLogID(); fileName = orderFileManagementDetailForm.getFileName(); fileContents = logID + "," + fileName + ",AAAA,BBBB,CCCC,DDDD,EEEE"; orderFileManagementDetailForm.setFileContents(fileContents); fileContents = ""; fileContents = orderFileManagementDetailForm.getFileContents(); } catch (Exception e) { } // Finish with forward = mapping.findForward("success"); return (forward); } } I have the form setup as such: package com.allstream.registry.beans; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; public class OrderFileManagementDetailForm extends ActionForm { private String logID = ""; private String fileName = ""; private String fileContents = ""; public void reset(ActionMapping mapping, HttpServletRequest request) { } /** * @return */ public String getLogID() { return logID; } /** * @param logID */ public void setLogID(String logID) { this.logID = logID; } /** * @return fileName */ public String getFileName() { return fileName; } /** * @param fileName */ public void setFileName(String fileName) { this.fileName = fileName; } /** * @return fileContents */ public String getFileContents() { return fileContents; } /** * @param fileContents */ public void setFileContents(String fileContents) { this.fileContents = fileContents; } } I have the jsp setup as such (please note, I'm just trying to get the page to open up an excel and load the data that's on the jsp for now. Once I get that going, i'll play around with it and try to load from a string. <% response.reset(); response.setHeader("Content-type","application/xls"); response.setHeader("Content-disposition","inline; filename=dans.csv"); %> Daniel,Dan,John,Dave,Don,Mac,Albert,Viren AAA,BBB,CCC,DDD,EEE,FFF,GGG,HHH N,,Y,N,,,Y,N I'm just trying to get the page to display after the action is finish running, but the page comes back blank. I've looked and played around for about 1.5 days and still frustrated. Here's the entry I have in my struts config file: Any help would most be appreciated. P.S. The jsp does work as posted because I can run it if I'm just debugging that page. Trying to get the page to come up while running through the application is my issue right now. Please help. Frustrated. :)

    Threaded Messages (2)

  2. Found the solution.[ Go to top ]

    I found the solution. Thanks to anyone who was thinking about looking into this.
  3. thanks a lot[ Go to top ]

    you might not be the only one having that kind of needs. When you post on a forum and find your own solution, try and be kind enough to post the solution, and not the laconic "ok, found it".