Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet to applet file transfer  RSS feed

 
Vijaishanker bala
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I am designing a web application in which lies a module which contains an applet which must receive a file stream from a servlet and attach it as an attachment using outlook(COM and jawin stuff). My problem is with the applet receiving the file stream from the servlet. The file stream coming in is either a zip file or a pdf file...I am using the URLConnection to initiate connection from the applet to the servlet...the code that does the connection is as follows

But in the place where I get the servlet's input stream, i.e. my file stream(zip/pdf), I get a class cast Exception...what could be possibly wrong...the servlet if I call from my browser gives me the file...Should I be casting it to something else?

Thanks

Vijai
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this has less to do with servlets than reading a file using URL Connection, I'm going to move it to Sockets and Internet Protocols.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The getInputStream method returns you an InputStream which is not a FileInputStream so the cast fails. Make your variable type a normal InputStream to read from that stream.

I think you'll find when you start reading it that the servlet sends you HTTP headers. Get a sniffer like HTTPLook to see what comes back when you request the file from a normal browser. Dig into the W3C docs on headers to see what they mean.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!