Boa tarde a todos, bom o problema é o seguinte eu possuo essa classe abaixo:
package action;
import java.io.IOException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteMethod;
import org.directwebremoting.annotations.RemoteProxy;
@RemoteProxy
@DataTransferObject
public class EditorAction {
/**
*
*/
private static final long serialVersionUID = 1L;
@RemoteMethod
public static void download(String content )
throws IOException {
String nomeArquivo = "Texto";
HttpServletResponse response = null;
response.setHeader("Content-Disposition", "attachment; filename=" + nomeArquivo + ".doc");
response.setContentType( "application/download" );
ServletOutputStream outStream = response.getOutputStream();
try {
outStream.print( content );
outStream.flush();
} finally {
outStream.close();
}
}
}
A finalidade dela é receber uma string e gerar um arquivo “.doc” e forçar o navegador a fazer o download do arquivo , bom mas na linha :
response.setHeader("Content-Disposition", "attachment; filename=" + nomeArquivo + ".doc");
Está ocorrendo um nullpointeException, alguém saberia o porque ? Ou uma outra forma de fazer isso que funcione, tipo eu não uso nem um framework web, somente dwr que chama essa classe no javascript.
Agradeço a qualquer ajuda…