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.setContentType(“application/x-download”);
res.setHeader(“Content-Disposition”, “attachment; filename=” + filename);

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

Advertisements

Remote Debug a java program

十月 12, 2007 @ 12:16 上午 | 发表在 Java | 留下评论

Add the following options while bringing up the application
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
To debug from a local machine, use
jdb -attach 8000
To debug from a remote machine, use
jdb -connect com.sun.jdi.SocketAttach:hostname=xxx.xx.xxx.xx,port=8000

在WordPress.com的博客.
Entries评论 feeds.