dcsimg
Get the right name of the attached files.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   diger_qiu
Posted On:   Thursday, October 25, 2001 07:29 PM

I have design a program to get the attach file from an attachment. But when I click the link to save the file, the default name of the file always is 'attach' whenever I get different files. I want to know what is the problem, please tell me the truth. Here are some codes of the program. download.jsp [a href="attachment?message='1'&part='1'"] [%="test.doc"%] web.xml [servlet-mapping] [servlet-name]AttachmentServlet[/servlet-name] [url-pattern]attachment[/url-pattern] [/servlet-mapping] AttachmentServlet.java public void doGet ....... Message msg = folder.getMessage(msgNum); // the message I get is right // an   More>>

I have design a program to get the attach file from an attachment. But when I click the link to save the file, the default name of the file always is 'attach' whenever I get different files. I want to know what is the problem, please tell me the truth.
Here are some codes of the program.

download.jsp
[a href="attachment?message='1'&part='1'"]
[%="test.doc"%]

web.xml
[servlet-mapping]
[servlet-name]AttachmentServlet[/servlet-name]
[url-pattern]attachment[/url-pattern]
[/servlet-mapping]

AttachmentServlet.java
public void doGet
.......
Message msg = folder.getMessage(msgNum);
// the message I get is right
// and the name of the file in
// the attach in this message
// is right too.(I have printed)

Multipart multipart = (Multipart)msg.getContent();
Part part = multipart.getBodyPart(partNum);

ContentType ct = new ContentType(sct);
response.setContentType(ct.getBaseType());
InputStream is = part.getInputStream();
int i;
while ((i = is.read()) != -1) {
out.write(i);
}
out.flush();
out.close();
...........

   <<Less

Re: Get the right name of the attached files.

Posted By:   John_Zukowski  
Posted On:   Sunday, October 28, 2001 06:17 PM

Dealling with attachments is already covered in the FAQ.
About | Sitemap | Contact