Results 1 to 2 of 2
- 06-04-2012, 04:15 PM #1
Member
- Join Date
- Jun 2012
- Posts
- 1
- Rep Power
- 0
Using getOutputStream() while getWriter() is open
Dear,
I've faced a problem with passing JSP parameter for PHP one using php-java bridge.
The point is, I have to implement some function which will used to read the input into out put stream inside filter. That's why, caused some kind of IllegalStateException conflict.
The code is,
Take in consideration that, the whole application use getWriter() while as mentioned before I have to used getOutputStream for response object.Java Code:HttpServletRequest httpRequest = (HttpServletRequest)request; HttpServletResponse httpResponse = (HttpServletResponse)response; RemoteHttpServletContextFactory ctx = new RemoteHttpServletContextFactory(null, null, httpRequest, httpRequest, httpResponse); if (response instanceof HttpServletResponse) { System.out.println(" Enter CompressionServletResponseWrapper "); CompressionServletResponseWrapper wrappedResponse = new CompressionServletResponseWrapper((HttpServletResponse)response); wrappedResponse.setCompressionThreshold(3000); wrappedResponse.setHeader("X_JAVABRIDGE_CONTEXT", ctx.getId()); wrappedResponse.setHeader("Pragma", "no-cache"); wrappedResponse.setHeader("Cache-Control", "no-cache"); try { HttpSession session = httpRequest.getSession(); session.setAttribute("par1", "a"); session.setAttribute("par2", "b"); ctx.handleRequests(httpRequest.getInputStream(), wrappedResponse.getOutputStream()); //httpResponse chain.doFilter(request, wrappedResponse); } catch (Exception ex) { } finally { wrappedResponse.finishResponse(); ctx.destroy(); }
So, how could we handle this?
ThanksLast edited by khkh82; 06-05-2012 at 08:34 AM.
- 06-06-2012, 12:20 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Re: Using getOutputStream() while getWriter() is open
None of that shows where you are using the streams.
None of that shows us your error.
Do you have an exception?
If so then post it in full here, and highlight the line in your code where it is thrown.
Also, do not ignore exceptions like that, at least printStackTrace().Please do not ask for code as refusal often offends.
Similar Threads
-
response.getOutputStream used on MySQL request throwing IllegalStateException in JSP
By blobs in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 05-11-2012, 09:40 AM -
getOutputStream() has already been called for this response
By zuzacat in forum New To JavaReplies: 0Last Post: 06-23-2011, 12:02 PM -
how to use window.open(...) in a jsp to call a servlet and open jsp in a new window.
By ajincoep in forum JavaServer Pages (JSP) and JSTLReplies: 4Last Post: 02-07-2011, 08:43 AM -
Different Files Open in File -> Open Workspace
By mgm2010 in forum JCreatorReplies: 0Last Post: 04-11-2009, 02:14 PM -
getOutputStream() exception
By Freddie in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 05-15-2007, 04:26 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks