The following code snippet only sends back the first 4 bytes of a .zip file, has an error with .doc but spits out a whole entire text file...
import com.oreilly.servlet.Base64Decoder;
private void testStream(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
HttpSession sess = req.getSession(false);
ServletOutputStream out = res.getOutputStream();
String fileName = (String) sess.getValue("fileName"
res.setContentType( "application/octetstream" );
res.setHeader( "Content-Disposition", "filename=" + fileName + ";" );
byte[] bytes = Base64Decoder.decode((String)sess.getValue("fileContents").getBytes();
out.write(bytes);
}
(String)sess.getValue("fileContents" correctly retrieves the Base64 encoded file... and like I said, it's working fine on text strings.
Anyone have an idea what I'm doing wrong here?
import com.oreilly.servlet.Base64Decoder;
private void testStream(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
HttpSession sess = req.getSession(false);
ServletOutputStream out = res.getOutputStream();
String fileName = (String) sess.getValue("fileName"
res.setContentType( "application/octetstream" );
res.setHeader( "Content-Disposition", "filename=" + fileName + ";" );
byte[] bytes = Base64Decoder.decode((String)sess.getValue("fileContents").getBytes();
out.write(bytes);
}
(String)sess.getValue("fileContents" correctly retrieves the Base64 encoded file... and like I said, it's working fine on text strings.
Anyone have an idea what I'm doing wrong here?