>>> Peter Corrigan <[EMAIL PROTECTED]> 25-Feb-00 10:08:52 AM >>>

>Can servlets pass a whole file out to the client?....
>Any pointers as to how one can do this?

Just read in the file and then send it out through the servlet
outputstream with the content type set to "application/word" (?)

eg:

  File handle=new File("m$-word-document-awfull.doc");
  FileInputStream fin=new FileInputStream(handle);
  int size=handle.size();
  byte[] buf=new byte[size];
  int red=fin.read(buf,0,size);
  //now send to client
  response.setContentType("application/m$-word");
  OutputStream out=response.getOutputStream();
  out.write(buf,0,size);
  out.close();


And Bob's your uncle and fanny is your aunt.

For security you'll probably want to send the UNAUTHORIZED response
if the session doesn't match up with what you want.

You could of course just use Realms instead of sessions. To know how
to do that check the archives and FAQ and so on.



Nic Ferrier

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to