I'm retrieving a given path file and would like to display the response in a Modal.
This is an excerpt of HTML that calls the servlet (MSD) by passing the file path as a parameter:
<a class="btn-doc-sm btn-default" type="button" href="MSD?p=d:/upload/documento.docx">
Visualizar
</a>
This is the portion of my servlet that retrieves the file and displays it:
String caminhoArquivo = request.getParameter("p");
File arquivo = new File(caminhoArquivo);
String nome = arquivo.getName();
int tamanhoArquivo = (int) arquivo.length();
response.setContentType(acao);
response.setContentLength(tamanhoArquivo);
response.setHeader("Content-Disposition", "filename=\"" + nome + "\"");
output = response.getOutputStream();
Files.copy(arquivo.toPath(), output);
With this snippet, I can retrieve the file and display it, but in a new tab.
Is there any way for the recovered file to be displayed in a modal?