[Beginners Corner] - Error while accessing servlet response
by BenitoJuarez
Hi,
i tried to access the servlet response to directly write binary data:
| HttpServletResponse response = (HttpServletResponse) javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getResponse();
|
| response.setContentType("application/octet-stream");
| response.addHeader("Content-Disposition","attachment;filename=productlist.xls");
|
| OutputStream writer = response.getOutputStream();
| wb.write(writer);
|
| writer.flush();
| writer.close();
|
| javax.faces.context.FacesContext.getCurrentInstance().responseComplete();
|
but response.getOutputStream() throws an exception:
| 15:30:11,190 ERROR [STDERR] java.util.MissingResourceException: Can't find bundle for base name org.ajax4jsf.messages, locale de_DE
| 15:30:11,190 ERROR [STDERR] at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1521)
| 15:30:11,190 ERROR [STDERR] at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1260)
| 15:30:11,190 ERROR [STDERR] at java.util.ResourceBundle.getBundle(ResourceBundle.java:962)
| 15:30:11,190 ERROR [STDERR] at org.ajax4jsf.Messages.getBundle(Messages.java:39)
| 15:30:11,190 ERROR [STDERR] at org.ajax4jsf.Messages.getMessage(Messages.java:47)
| 15:30:11,190 ERROR [STDERR] at org.ajax4jsf.webapp.FilterServletResponseWrapper.getOutputStream(FilterServletResponseWrapper.java:252)
| 15:30:11,190 ERROR [STDERR] at javax.servlet.ServletResponseWrapper.getOutputStream(ServletResponseWrapper.java:102
|
i'm happy for any hint about that
Thx
BJ
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4212277#4212277
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4212277
17 years, 2 months
[JBoss Portal] - Re: Session timeout
by KorayCetinbas
A late reply but i think writing a wrapper for a4jfilter and setting the new filter as ajax filter in web.xml may solve your problem.
(Of course you need to refresh the last activity time, or do something else to suit your needs, after casting to httpservletrequest)
| public class MyAjaxFilter extends Filter
| {
| public void doFilter(ServletRequest req, ServletResponse res, FilterChain fc) throws IOException, ServletException {
| try
| {
| HttpServletRequest httpReq = ((HttpServletRequest)(req));
| // do what you need to do about the session variables
| super.doFilter(req, res, fc);
| }
| catch (Exception exp)
| {
|
| }
| }
| }
|
Hope this helps,
Koray
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4212271#4212271
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4212271
17 years, 2 months