Re: how to set chunk size?
Thanks Bill, I already wrote a servlet that send chunked data, but since i saw in tomcat document that tomcat support it, i thought it is something i can configure . any way if my client support chunks i saw with wireshark that chunks size are 2000 byte with default servlet , looks to me like default behavior of tomcat. so probably you can set this value, so tomcat will do the job for me ( maybe better then me ??? :) ) , so again - where to do it? Regards Lior On 7/10/07, Bill Barker [EMAIL PROTECTED] wrote: lior grinfeld [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, i am trying to find out where and which attribute i can use to do transfer data as chunk and determined the chunk size of a response. i saw it is supported, i read it in the Apache Tomcat Configuration Reference - The HTTP Connector, but where can i find more details? Section 5.1 of the Servlet spec might be a start :). Setting the bufferSize on the response (assuming that this is a Servlet, not a JSP) should make it close to the chunk size (assuming you don't set it too small, like under 8Kb). There isn't really a practical way to guarantee the chunk size. You would have to count bytes sent, and call response.flushBuffer at the magic number to have any chance of controlling the chunk size. However, this should be a waste of time, since any working HTTP/1.1 client would know how to parse the chunk size sent in the response body. thanks Lior - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Regards Lior Grinfeld
how to set chunk size?
Hi, i am trying to find out where and which attribute i can use to do transfer data as chunk and determined the chunk size of a response. i saw it is supported, i read it in the Apache Tomcat Configuration Reference - The HTTP Connector, but where can i find more details? thanks Lior
Re: how to manipulate static content
Thanks Pierre, for sure i will use that info, but now i am not writing a server, as i wrote earlier, i use tomcat to test a proxy. i am interested to see how my proxy behave when i send it the data chunked or zip the data. and i want this to be in reference to regular files. so basically all i want is to use the default servlet to return static content in one test and afterwards to return the same content but this time it will be zip or use chunk to transfer the content. i do not want to write servlets to each one of the behaviors, that i why i thought that the idea of writing filter (by David) was good. if i could do some kind of HttpServletResponseWrapper (as i saw in the j2ee tutorial) it will be excellent. Regards Lior On 7/4/07, Pierre Goupil [EMAIL PROTECTED] wrote: Lior, Basically, I think that you need to handle the response by yourself. For instance, if you want to send an image : *** RenderedImage rimg = ImageIO.read(new File(img)); OutputStream os = response.getOutputStream(); // === get the response to be able to re-write it ImageIO.write(rimg, jpg, os); os.close(); *** In my example I assumed that the MIME content-type was set to the relevant value, since you said that your headers were OK. But anyway, here is my stuff to do so : *** response.setContentType(image/jpg); *** But if you want to be able to send a file for the browser to download it, or to be able to send several different types of data all in one response, you need a multi-part response : *** response.setHeader(Content-Disposition, attachment;filename=\test.doc\ ); // === here response.setContentType(text/doc); out = response.getWriter(); out.print(what you wish); response.setContentType(image/png); out = response.getWriter(); out.print(what you wish too); out.close(); *** Be aware that without a multi-part response, you can only set one content-type. If you try and set it a second time, Tomcat will give you a (beautiful) exception saying something like (can't remember exactly) content-type has already been set. Here is a list of MIME-types, FYI : http://plugindoc.mozdev.org/winmime.html With this technique of multi-part response, you can for instance turn a JSP to a Word file : you set the response type to .doc and let Tomcat render its JSP compiled to HTML into it. Then the browser received a .doc file with regular HTML into it, which word is able to read... et voilà ! Regards, Pierre 2007/7/4, lior grinfeld [EMAIL PROTECTED]: you were right, 10X. now i am facing yet one more challenge. i made filter to overwrite the response, i added headers as i want and it works fine. now i want to manipulate the content , to do zip or to chunk the data. i tried to do StreamResponseWrapper that extends HttpServletResponseWrapper, without success. any ideas on how to implement it? 10X Lior On 7/4/07, David Delbecq [EMAIL PROTECTED] wrote: Could it be you forgot to call filterChain.doFilter(request.response) after adding your headers? En l'instant précis du 04/07/07 14:18, lior grinfeld s'exprimait en ces termes: Thanks for the tip, i used filters. now i facing other problem. if I use filter with request to static content ( i did not write servlet for it , i want the defaultServlet to handle it) for some reason i do not get the content, it looks like the defaultServlet is doing nothing now, without filter it return the file i ask, with filter just the data the filter added. any ideas? 10X Lior On 7/4/07, David Delbecq [EMAIL PROTECTED] wrote: Either map to '/*' your custom servlet that returning the static content with your custom headers, either write a servletfilter that add additional header before processing request. En l'instant précis du 04/07/07 09:52, lior grinfeld s'exprimait en ces termes: Hi, i am new at using tomcat. I want to use tomcat as a server to test our proxy. to do that i need to manipulate the response headers, i did that without problems using servlets. now i want to manipulate the http response headers or content of requests for static content. Ex. if i will do GET myServer/somefile.txt the tomcat will know to return the file and manipulate the response http headers as i want, or to do zip or to do chunks on the content. is it possible and how? where can i configure tomcat to refer to the directory where all my files are stored? - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail
Re: how to manipulate static content
Thanks Pierre, for sure i will use that info, but now i am not writing a server, as i wrote earlier, i use tomcat to test a proxy. i am interested to see how my proxy behave when i send it the data chunked or zip the data. and i want this to be in reference to regular files. so basically all i want is to use the default servlet to return static content in one test and afterwards to return the same content but this time it will be zip or use chunk to transfer the content. i do not want to write servlets to each one of the behaviors, that i why i thought that the idea of writing filter (by David) was good. if i could do some kind of HttpServletResponseWrapper (as i saw in the j2ee tutorial) it will be excellent. Regards Lior On 7/4/07, Pierre Goupil [EMAIL PROTECTED] wrote: Lior, Basically, I think that you need to handle the response by yourself. For instance, if you want to send an image : *** RenderedImage rimg = ImageIO.read(new File(img)); OutputStream os = response.getOutputStream(); // === get the response to be able to re-write it ImageIO.write(rimg, jpg, os); os.close(); *** In my example I assumed that the MIME content-type was set to the relevant value, since you said that your headers were OK. But anyway, here is my stuff to do so : *** response.setContentType(image/jpg); *** But if you want to be able to send a file for the browser to download it, or to be able to send several different types of data all in one response, you need a multi-part response : *** response.setHeader(Content-Disposition, attachment;filename=\test.doc\ ); // === here response.setContentType(text/doc); out = response.getWriter(); out.print(what you wish); response.setContentType(image/png); out = response.getWriter(); out.print(what you wish too); out.close(); *** Be aware that without a multi-part response, you can only set one content-type. If you try and set it a second time, Tomcat will give you a (beautiful) exception saying something like (can't remember exactly) content-type has already been set. Here is a list of MIME-types, FYI : http://plugindoc.mozdev.org/winmime.html With this technique of multi-part response, you can for instance turn a JSP to a Word file : you set the response type to .doc and let Tomcat render its JSP compiled to HTML into it. Then the browser received a .doc file with regular HTML into it, which word is able to read... et voilà ! Regards, Pierre 2007/7/4, lior grinfeld [EMAIL PROTECTED]: you were right, 10X. now i am facing yet one more challenge. i made filter to overwrite the response, i added headers as i want and it works fine. now i want to manipulate the content , to do zip or to chunk the data. i tried to do StreamResponseWrapper that extends HttpServletResponseWrapper, without success. any ideas on how to implement it? 10X Lior On 7/4/07, David Delbecq [EMAIL PROTECTED] wrote: Could it be you forgot to call filterChain.doFilter(request.response) after adding your headers? En l'instant précis du 04/07/07 14:18, lior grinfeld s'exprimait en ces termes: Thanks for the tip, i used filters. now i facing other problem. if I use filter with request to static content ( i did not write servlet for it , i want the defaultServlet to handle it) for some reason i do not get the content, it looks like the defaultServlet is doing nothing now, without filter it return the file i ask, with filter just the data the filter added. any ideas? 10X Lior On 7/4/07, David Delbecq [EMAIL PROTECTED] wrote: Either map to '/*' your custom servlet that returning the static content with your custom headers, either write a servletfilter that add additional header before processing request. En l'instant précis du 04/07/07 09:52, lior grinfeld s'exprimait en ces termes: Hi, i am new at using tomcat. I want to use tomcat as a server to test our proxy. to do that i need to manipulate the response headers, i did that without problems using servlets. now i want to manipulate the http response headers or content of requests for static content. Ex. if i will do GET myServer/somefile.txt the tomcat will know to return the file and manipulate the response http headers as i want, or to do zip or to do chunks on the content. is it possible and how? where can i configure tomcat to refer to the directory where all my files are stored? - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail
manipulating http header connection type
Hi how can i set which connection type tomcat use? (keep-alive, close) can i change it with the servlet code? response.setHeader(connection, keep-alive); if yes, why it did not work for me and tomcat send always connection: close ? and .. can i change the http version from servlet to servlet? or to change the http version in run time using configuration files? -- Regards Lior Grinfeld
how to manipulate static content
Hi, i am new at using tomcat. I want to use tomcat as a server to test our proxy. to do that i need to manipulate the response headers, i did that without problems using servlets. now i want to manipulate the http response headers or content of requests for static content. Ex. if i will do GET myServer/somefile.txt the tomcat will know to return the file and manipulate the response http headers as i want, or to do zip or to do chunks on the content. is it possible and how? where can i configure tomcat to refer to the directory where all my files are stored? -- Thanks Lior Grinfeld -- Regards Lior Grinfeld
Re: how to manipulate static content
Thanks for the tip, i used filters. now i facing other problem. if I use filter with request to static content ( i did not write servlet for it , i want the defaultServlet to handle it) for some reason i do not get the content, it looks like the defaultServlet is doing nothing now, without filter it return the file i ask, with filter just the data the filter added. any ideas? 10X Lior On 7/4/07, David Delbecq [EMAIL PROTECTED] wrote: Either map to '/*' your custom servlet that returning the static content with your custom headers, either write a servletfilter that add additional header before processing request. En l'instant précis du 04/07/07 09:52, lior grinfeld s'exprimait en ces termes: Hi, i am new at using tomcat. I want to use tomcat as a server to test our proxy. to do that i need to manipulate the response headers, i did that without problems using servlets. now i want to manipulate the http response headers or content of requests for static content. Ex. if i will do GET myServer/somefile.txt the tomcat will know to return the file and manipulate the response http headers as i want, or to do zip or to do chunks on the content. is it possible and how? where can i configure tomcat to refer to the directory where all my files are stored? - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Regards Lior Grinfeld
Re: how to manipulate static content
you were right, 10X. now i am facing yet one more challenge. i made filter to overwrite the response, i added headers as i want and it works fine. now i want to manipulate the content , to do zip or to chunk the data. i tried to do StreamResponseWrapper that extends HttpServletResponseWrapper, without success. any ideas on how to implement it? 10X Lior On 7/4/07, David Delbecq [EMAIL PROTECTED] wrote: Could it be you forgot to call filterChain.doFilter(request.response) after adding your headers? En l'instant précis du 04/07/07 14:18, lior grinfeld s'exprimait en ces termes: Thanks for the tip, i used filters. now i facing other problem. if I use filter with request to static content ( i did not write servlet for it , i want the defaultServlet to handle it) for some reason i do not get the content, it looks like the defaultServlet is doing nothing now, without filter it return the file i ask, with filter just the data the filter added. any ideas? 10X Lior On 7/4/07, David Delbecq [EMAIL PROTECTED] wrote: Either map to '/*' your custom servlet that returning the static content with your custom headers, either write a servletfilter that add additional header before processing request. En l'instant précis du 04/07/07 09:52, lior grinfeld s'exprimait en ces termes: Hi, i am new at using tomcat. I want to use tomcat as a server to test our proxy. to do that i need to manipulate the response headers, i did that without problems using servlets. now i want to manipulate the http response headers or content of requests for static content. Ex. if i will do GET myServer/somefile.txt the tomcat will know to return the file and manipulate the response http headers as i want, or to do zip or to do chunks on the content. is it possible and how? where can i configure tomcat to refer to the directory where all my files are stored? - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Regards Lior Grinfeld