The Artima Developer Community
Sponsored Link

Java Answers Forum
Response wrapper problem ?!!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Hany

Posts: 1
Nickname: hany
Registered: Sep, 2003

Response wrapper problem ?!! Posted: Sep 2, 2003 3:35 AM
Reply to this message Reply
Advertisement
Hi,

I spent nearly 3 weeks on a response wrapping problem, I didn't yet figured out the cause, I'm working with JDK 1.4 + servlet 2.3 + struts rc2 MVC framework + tiles on JRUN web server.
the problem arise when I tried to filter struts actions (*.do) with a wrapping filter, i.e. in WEB.XML I wrote :

<filter>
<filter-name>My Response Wrapper</filter-name>
<filter-class>filters.WrapperFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>My Response Wrapper</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>

the code in my filter WrapperFilter.java is :

OutputStream out = response.getOutputStream();
out.write("<HR>PRE HTML FOR TEST <HR>".getBytes());
GenericResponseWrapper wrapper = new GenericResponseWrapper ((HttpServletResponse) response);
chain.doFilter(request, wrapper);
out.write(wrapper.getData());
out.write("<HR>POST HTML FOR TEST<HR>".getBytes());
out.close();

so , when calling any action servlet in browser ,the page shows NOTHING and the logged error is :

jrun.servlet.io.ClosedIOException: Response has been closed
at jrun.servlet.io.ClosedOutputStream.write(ClosedOutputStream.java:23)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)
at jrun.servlet.http.WebOutputStream.write(WebOutputStream.java:64)
at java.io.OutputStream.write(OutputStream.java:58)
at filters.WrapperFilter.doFilter(WrapperFilter.java:176)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
at jrun.servlet.FilterChain.service(FilterChain.java:101)
.....


Also I noticed that the filter is working fine if my action is forwarding to a JSP page instead of a tiles definition name
so instead of mapping the filter to *.do I mapped it to *.jsp :

<filter-mapping>
<filter-name>My Response Wrapper</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>

that time the page shows correctly with the pre/post text embedded.
I'm confused, is it a struts , tiles or JRUN problem ?

any help will be appreciated.

Regards.

Topic: multiple .jar files in CLASSPATH ? Previous Topic   Next Topic Topic: Java I/O Problem(Thanks)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use