This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes A problem with servlet file transfer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "A problem with servlet file transfer" Watch "A problem with servlet file transfer" New topic
Author

A problem with servlet file transfer

Pham Minh An
Greenhorn

Joined: Aug 28, 2011
Posts: 5
I am a new Java programer. I have a example for sent file.(word file. Using ms-word 2003). The file is downloaded successful but it can't open. The ms-word messages are: "Word experienced an error trying to open the file. Try these suggestions......". This's my code:


The word file template's content: text and image(jpg). The file size: 116KB. i am looking forward to hearing from you.
Thanks...
olivier dutranoit
Ranch Hand

Joined: Aug 20, 2011
Posts: 81

"The file is downloaded successful but it can't open"

are you sure the file is correct? I think your client receives an empty file...or with junk in it...

save the file on the client and check its content...if its not good, there must be a problem with your original file, or your servlet's code!

Pham Minh An
Greenhorn

Joined: Aug 28, 2011
Posts: 5
Thanks for reply, olivier dutranoit. If the file's content are only text, it's ok. But, If i insert images or new lines, the error message is display.
Pham Minh An
Greenhorn

Joined: Aug 28, 2011
Posts: 5
Nobody else? I need solution. Help me, please!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

A post that goes unanswered usually means that you have not provided enough information on the problem. So rather than posting useless bumps like that last one, provide more information that can help solve the problem.

For example, what have you done too ensure that the file is correctly formatted? How is the file being generated in the first place? And so on.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: A problem with servlet file transfer
 
Similar Threads
bytearray image decoding
Video Player
IllegalStateException after canceling file downloading.
Opening a PDF
going to a particular page in a pdf