File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes cannot call getWriter() after getOutputStream() error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "cannot call getWriter() after getOutputStream() error " Watch "cannot call getWriter() after getOutputStream() error " New topic

cannot call getWriter() after getOutputStream() error

chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 197

I am using my-faces 2.1.5 primefaces 3.2 and WebLogic Server Version:
While I am generating files and trying to download them via p:fileDownload I get the following error message:

java.lang.IllegalStateException: strict servlet API: cannot call getWriter() after getOutputStream()
at weblogic.servlet.internal.ServletResponseImpl.getWriter(
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.getResponseOutputWriter(
at org.apache.myfaces.renderkit.ErrorPageWriter.handle(
at org.apache.myfaces.context.MyFacesExceptionHandlerWrapperImpl.handle(
at javax.faces.context.ExceptionHandlerWrapper.handle(
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(
at javax.faces.webapp.FacesServlet.service(
at weblogic.servlet.internal.StubSecurityHelper$
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(
at weblogic.servlet.internal.ServletStubImpl.execute(
at weblogic.servlet.internal.TailFilter.doFilter(
at weblogic.servlet.internal.FilterChainImpl.doFilter(
at weblogic.servlet.internal.RequestEventsFilter.doFilter(
at weblogic.servlet.internal.FilterChainImpl.doFilter(
at weblogic.servlet.internal.WebAppServletContext$
at weblogic.servlet.internal.WebAppServletContext.securedExecute(
at weblogic.servlet.internal.WebAppServletContext.execute(

I don’t know if it’s a bug in the weblogic or perhaps it’s a bug in my code ?
This message is the only reference that I got and I don’t have any clue how to solve this issue

Any help would be great


chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 197
some code example:

My bean:
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

JSF is designed to facilitate working with HTML forms. It's not a good fit for things like producing non-HTML output like PDF's, XML data output, or MS-Word documents. It's also not intended to be used as a thin wrapper over the traditional servlet outputstream. It's a complete self-contained subsystem and you'll only annoy it if you attempt to meddle with its basic flows.

To output non-HTML, it's better just to hand off the job to a traditional servlet or JSP.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: cannot call getWriter() after getOutputStream() error
It's not a secret anymore!