DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7942>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7942 test for a Filter wrapping a servlet fails Summary: test for a Filter wrapping a servlet fails Product: Tomcat 4 Version: Nightly Build Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Critical Priority: Other Component: Catalina AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] The folowing Filter should add some discription (a html table) as part of the response. But the response lost that part. public class FilterWEG extends GenericFilter { public FilterWEG () { log("FilterWEG initialized"); } public void doFilter(final ServletRequest request, final ServletResponse response, FilterChain chain) throws java.io.IOException, javax.servlet.ServletException { String message = "Filtered !"; GenericResponseWrapper wrapper = new GenericResponseWrapper ((HttpServletResponse)response); chain.doFilter(request, wrapper); ServletOutputStream out = response.getOutputStream(); //message = getFilterConfig().getInitParameter("message"); ByteArrayOutputStream respStream = manipulateResp(wrapper.output()); response.setContentLength(respStream.size()); response.setContentType("text/html"); out.write(respStream.toByteArray()); // the following should appear in the response out.println("<p><p>"); out.println("<p>This table is generated from the FilterWEGS<p>"); out.println("<table BORDER COLS=2 WIDTH=\"100%\" NOSAVE >"); out.println("<tr>"); out.println("<td>Test Name:</td>"); out.println("<td>FilterERES</td>"); out.println("</tr>"); out.println("<tr>"); out.println("<td>CharacterEncoding:</td>"); out.println("<td>"+response.getCharacterEncoding()+"</td>"); out.println("</tr>"); out.println("<tr>"); out.println("<td>Result:</td>"); out.println("<td>The content before this table should be all capital</td>"); out.println("</tr>"); out.println("<tr>"); out.println("<td>Author:</td>"); out.println("<td>James</td>"); out.println("</tr>"); out.println("</table>"); out.println("</body>"); out.println("</html>"); out.flush(); out.close(); } public ByteArrayOutputStream manipulateResp(byte[] respData) throws ServletException { //change every character in the response to higher case int i; int o; char a='a'; char A='A'; int diff = A-a; ByteArrayInputStream readStream; ByteArrayOutputStream respStream; respStream = new ByteArrayOutputStream(); try{ readStream = new ByteArrayInputStream(respData); do { i = readStream.read(); //log("get char:"+((char) i)); //log("FilterWEG 125: read readStream"); if (i != -1) { if ( (((char) i)>='a')&&(((char) i)<='z') ) { o= i+diff; respStream.write(o); } else { respStream.write(i); } } } while (i != -1); readStream.close(); } catch (IOException e) { System.out.println("IOExcption:" + e); } return respStream; } } This filter is mapped to a servlet named FilterWEGServlet (which is just a single line printout). But the output does not contain the "table" add in the filter. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>