[jboss-user] [JBoss Portal] New message: "please help me, a jboss portal problem"
max liu
do-not-reply at jboss.com
Mon Jan 18 06:40:50 EST 2010
User development,
A new message was posted in the thread "please help me,a jboss portal problem":
http://community.jboss.org/message/520555#520555
Author : max liu
Profile : http://community.jboss.org/people/liumax
Message:
--------------------------------------------------------------
public String download() {
ActionResponseImpl response = (ActionResponseImpl) FacesContext
.getCurrentInstance().getExternalContext().getResponse();
try {
downloadFile(response,"","");
return "";
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// FacesContext.getCurrentInstance().responseComplete();
return null;
}
public void downloadFile(ActionResponseImpl response, String realName,
String fileName) throws IOException {
System.out.println(response.getClass());
response.getRealResponse().setHeader("Content-Disposition",
"attachment; filename=b.rar");
OutputStream output = response.getRealResponse().getOutputStream();
byte[] b = new byte[1024];
int i = 0;
FileInputStream fis = new FileInputStream("c:/upload/upload2/b.rar");
while ((i = fis.read(b)) > 0) {
output.write(b, 0, i);
}
output.flush();
output.close();
}
sorry,i speak english is not very well,so i used google translation to send message to here.my project(jbossportal+jsf) has a problem.it is an download development,i can not download rar or doc file.it will be opened in IE.the problem is "response.getRealResponse().setHeader()" can not do anything.please help me,thank you evenybody
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/520555#520555
More information about the jboss-user
mailing list