Daniel Blumenthal wrote:

Hi there, and happy holidays!

U 2.

I usually have an action pick up the binary stream (and related info), put it in the request scope and then forward to a servlet responsible for building the response using that info from the request context. Never liked actions that actually produce the request.

hth,

Manos



I have an application in which there are certain files which are only
accessible by certain users.  So, when a request comes to my "GetFile"
Action, I first verify that they have the correct permissions, then send the
file by opening the file and reading it into the response output stream
(code included below).  This works, but seems unbelievably hacky, and I was
wondering if there were a better way to do this.

Thanks!

Daniel

the code:

  response.reset();
  response.setContentType(mimeType);

File f = new File(path); long filelen = f.length();
  response.setContentLength((int)filelen);
FileInputStream fileIn = new FileInputStream(f);
  BufferedInputStream bufIn = new BufferedInputStream(fileIn);
  BufferedOutputStream out = new
BufferedOutputStream(response.getOutputStream());
final int READ_SIZE = 1024;
  int count;
  byte[] buffer = new byte[READ_SIZE];
  while ((count = bufIn.read(buffer,0,READ_SIZE)) != -1)
    out.write(buffer,0,count);
out.flush();
  out.close();
response.flushBuffer();





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to