java code to export file from java application which is deployed in Unix Server to windows PC

I have a java application which I runs as expected on localhost (Windows 7). Basically the purpose of this application is to pull the data from database and display's on screen, if user wants this content to export it to his local machine then he can export it. This working as expected from my local machine (windows 7). After deploying the WAR file in Unix server and run it, then it is looking for location that I gave, it's not downloading the file. Here is the exception that I'm getting...

Error while generating report: C:/ArchieveTool/ArchieveTool/output/02012014020842.xls (No such file or directory)

java.lang.NullPointerException

at java.io.File.<init>(File.java:277)

at com.sw.sirax.process.MainServlet.exportFile(Unknown Source)

at com.sw.sirax.process.MainServlet.doPost(Unknown Source)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:205)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:744)

Here is the piece of code that I'm using to export the file:

enter code here

public String createExcelReport(DataHelper helper) throws Exception{

logger.finest("Entering");

Workbook wb = new HSSFWorkbook();

setCellData(helper, wb);

SimpleDateFormat format = new SimpleDateFormat("MMddyyyyhhmmss");

String filePath = "C:/ArchieveTool/ArchieveTool/output/" + System.getProperty("file.separator") + "ArchiveUtility_" + format.format(new Date()) + ".xls";

FileOutputStream stream = new FileOutputStream(filePath);

wb.write(stream);

stream.close();

logger.finest("Exiting");

return filePath;

}

private String generateReport(DataHelper helper){

String filePath = null;

try{

ExcelGenerator generator = new ExcelGenerator();

filePath = generator.createExcelReport(helper);

}catch(Exception ex){

logger.severe("Error while generating report: " + ex.getMessage());

}

return filePath;

}

Please let me know what to change in the code If I need to download that file to downloads folder in win 7 from application which is running on UNIX server...

please someone assist me here.

1 answer

This widget could not be displayed.

Could you explain what this has to do with Atlassian products?

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

111 views 15 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you