"Eric B." <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I have a simple filter whose goal is to set the content type for a page. > However, when I check the actual headers that are returned by the server, > I see that they have been overridden by something in Tomcat; I'm just not > sure what / where this is happening. > > > I am using tomcat 6.0.14. > > This is my filter( stripped down): > public void doFilter( ServletRequest servletRequest, ServletResponse > servletResponse, FilterChain chain ) throws IOException, ServletException > { > // map to http > HttpServletRequest request = (HttpServletRequest) servletRequest; > HttpServletResponse response = (HttpServletResponse) servletResponse; > > servletResponse.setContentType( "text/css" ); > > // continue > chain.doFilter( servletRequest, servletResponse ); > } > > > I see my filter firing properly, but when I look at the returned headers, > the content type is set to "text/html". > > Does Tomcat set the ContentType after running executing the filters? Is > there a way to override a contentType set in web.xml? >
After further debugging, I noticed that my compiled JSP class file has a response.setContentType( "text/html" ) as pretty much the first functional line in the _jspService() method. I checked my jsp file and don't have that anywhere... is this something that Jasper adds in automatically? Is there a way to avoid it? public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); ..... } >From a quick glance, it seems as though all my compiled JSP pages have this in there... Is there anything I can do about it? Thanks, Eric --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]