Open File in Modal Dialog

Asked

Viewed 201 times

1

I am recovering a file given a path and would like to display the answer in a Modal.

This is a snippet of HTML that calls Servlet (MSD) by passing the file path as parameter:

<a class="btn-doc-sm btn-default" type="button" href="MSD?p=d:/upload/documento.docx">
    Visualizar
</a>

This is the snippet from my Serrvlet 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 recover the file and display it, however in a new tab.

Is there any way that the recovered file gets displayed in a modal?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.