I am trying to get the response back from the servlet which is essentially a ".csv" file. I upload a file to the server parse it read it and then if there are any errors in the file I write it into CSV file and send it back in response. But it seems that the response never come back to onSubmitComplete. Here is my code.
if (!errorContents.isEmpty()) {
CSVWriter csv = null;
try{
String filename = "errorList.csv";
resp.setContentType("text/plain");
resp.setHeader("Content-Disposition", "attachment; filename="" + filename + """);
csv = new CSVWriter(new OutputStreamWriter(resp.getOutputStream()));
for (String[] row : errorContents) {
csv.writeNext(row);
}
}finally {
csv.close();
}
} else {
resp.setContentType("text/plain");
resp.getWriter().write("Successful Processing");
}
现在客户端控制器的代码
formPanel.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
@Override
public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) {
controller.reloadAll();
com.google.gwt.user.client.Window.alert(event.getResults().toString());
hideContentDiv();
// loading.hide();
}