Use content-disposition to provide a save-as popup on browser

一月 21, 2008 @ 8:17 下午 | 发表在 J2EE, Java | 留下评论

Often times you need to prompt user a save-as dialog box with a default file name. This can be done through the content-disposition HTTP header. A sample java code snippet follows:

// Set the headers.
res.setHeader(“Content-Disposition”, “attachment; filename=” + filename);

// Send the file.
OutputStream out = res.getOutputStream(  );


发表评论 »

RSS feed for comments on this post. TrackBack URI


Fill in your details below or click an icon to log in: 徽标

You are commenting using your account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )


Connecting to %s

通过访问 创建免费网站或博客.
Entries评论 feeds.

%d 博主赞过: