Juan Zapato

Greenhorn
+ Follow
since Jul 23, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Juan Zapato

I try it something like this:

<code>

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class ProbServlet extends HttpServlet{

public void processImpresion(HttpServletRequest req, HttpServletResponse res) throws Exception {

String fileName = null;
String pdfBasePath = null;

fileName = something.getFileName();


File filePdf = new File(fileName);

FileInputStream fInp = new FileInputStream(filePdf);


FileOutputStream fOut = new FileOutputStream(getServletContext().getRealPath("")+System.getProperty("file.separator")+"pdf"+System.getProperty("file.separator")+fileName);
int BUFFER = 1024;
int count=0;
byte data[] = new byte[BUFFER];
BufferedInputStream bis = new BufferedInputStream(fInp,BUFFER);
while ( (count = bis.read(data, 0, BUFFER)) != -1)
{
fOut.write(data, 0, count);
}
fOut.flush();
fOut.close();
res.setContentType("application/pdf");
req.getRequestDispatcher("pdf/" + fileName).forward(req,res);
}

}
</code>
18 years ago
No on the other maschine but some other class find it I only need to read file from that location temporary save to app server and then show it in new window, so how that servlet finds the file doesn't really metter.
Thks!
18 years ago
I wanna now if somebody can explain me easiest way to copy file from some source to app. server and then show it in the browser.
Thanks!
18 years ago