Results 1 to 2 of 2
  1. #1
    khkh82 is offline Member
    Join Date
    Jun 2012
    Posts
    1
    Rep Power
    0

    Default 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,

    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();
                }
    Take in consideration that, the whole application use getWriter() while as mentioned before I have to used getOutputStream for response object.

    So, how could we handle this?

    Thanks
    Last edited by khkh82; 06-05-2012 at 09:34 AM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default 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.

    ** This space for rent **

Similar Threads

  1. Replies: 2
    Last Post: 05-11-2012, 10:40 AM
  2. Replies: 0
    Last Post: 06-23-2011, 01:02 PM
  3. Replies: 4
    Last Post: 02-07-2011, 09:43 AM
  4. Different Files Open in File -> Open Workspace
    By mgm2010 in forum JCreator
    Replies: 0
    Last Post: 04-11-2009, 03:14 PM
  5. getOutputStream() exception
    By Freddie in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 05-15-2007, 05:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •