6
I have a Java WEB application where I am using a Function that opens the file .pdf which I determine, but it only opens the files .pdf that are in the same folder where this saved my project, already tried to change my variable String
that calls the file .pdf and put the Access path, for example, "C: test.pdf" however it never finds the file if I put the path together, it is possible to change the access path of the files?
<%
String arquivo = "";
String i = "";
try {
if (request.getParameter("nomeArq").contains("null")){
arquivo = request.getAttribute("nomeArquivo").toString();
}else{
arquivo = request.getParameter("nomeArq");
}
} catch (Exception e) {
arquivo = request.getAttribute("nomeArquivo").toString();
}
try {
i = request.getParameter("numeroPag").toString();
} catch (Exception a) {
i = request.getAttribute("pagina").toString();
}
%>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
window.onload = function abrirPdf() {
var iframe = $("#LoteSlips");
iframe.attr("src", '<%=arquivo%>_ERRO.pdf#zoom=200&page=<%=i%>');
};
});
</script>
java? The code looks more like jquery
– user28595
For that you would have to use the
file://
src and run Chrome (for example) throughcmd
passing as parameter the--allow-file-access-from-files
. The browser for security reasons does not allow access to the files on the client’s machine.– Filipe Moraes
Unless the application works only locally (and it still makes little sense), it makes no sense what you want, otherwise use the absolute path using the protocol
http
or the relative path to the file based on the directory where the script is located.– Filipe Moraes
@Filipemoraes Would you be able to give me an example of how to do this and where I would make these changes? Because what I need is to be able to change in funtion the directory where my *.pdf files are without having to be saved along with the project.
– R.Santos
Is your application just to work locally? Do you have PHP installed locally? How is your environment at the moment?
– Filipe Moraes
At the moment I have a jsp page that creates a table with the name of the files. pdf that are in the directory "C: test", for example, from there when I click on open the command for this page to view the pdf the name of the selected file, but as I can not change the path in Function "C: test_arq_pdf" I need to save the files also along with my project, I will edit the question to show how this my page view pdf
– R.Santos
Are you using Struts? which version?
– David Schrammel
@Davidschrammel Struts?
– R.Santos