You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Anton Melser <me...@gmail.com> on 2007/07/02 16:09:02 UTC

problems with mod_jk modifying headers

(maybe a repost?)
Hi all,
We are running tomcat 5.5.23 on java 1.6.0 (suse 10.0 with addon java6
rpms for suse 10.1). These machines are load balanced behind an apache
2.2.2 with mod_jk jakarta-tomcat-connectors-1.2.15 (both compiled from
sources). We have a page that is showing the html source instead of
the page on firefox2. The funny thing is that when the page is
accessed directly then the content type is text/html (and the page
shows correctly) but when coming through mod_jk, it is coming as
text/plain (and showing the source). This doesn't seem to bother
IE7...
Does anyone have any ideas?
Cheers

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: problems with mod_jk modifying headers

Posted by Anton Melser <me...@gmail.com>.
On 04/07/07, Anton Melser <me...@gmail.com> wrote:
> On 04/07/07, Bill Barker <wb...@wilshire.com> wrote:
> >
> > "Anton Melser" <me...@gmail.com> wrote in message
> > news:92d3a4950707020709p6dbc7b51md505ac0137b86199@mail.gmail.com...
> > > (maybe a repost?)
> > > Hi all,
> > > We are running tomcat 5.5.23 on java 1.6.0 (suse 10.0 with addon java6
> > > rpms for suse 10.1). These machines are load balanced behind an apache
> > > 2.2.2 with mod_jk jakarta-tomcat-connectors-1.2.15 (both compiled from
> > > sources). We have a page that is showing the html source instead of
> > > the page on firefox2. The funny thing is that when the page is
> > > accessed directly then the content type is text/html (and the page
> > > shows correctly) but when coming through mod_jk, it is coming as
> > > text/plain (and showing the source). This doesn't seem to bother
> > > IE7...
> > > Does anyone have any ideas?
> >
> > Well, the default content-type for httpd is text/plain, so if you have a
> > controller servlet something like:
> >
> >    protected void doGet(HttpServletRequest req, HttpServletResponse res)
> >      throws ServletException, IOException {
> >         req.setAttribute("myBean", myBean);
> >         RequestDispatcher rd =
> > getServletContext().getRequestDispatcher("/WEB-INF/jsps/display.jsp");
> >         rd.include(req, res);
> >     }
> >
> > Then the JSP page will not be able to add it's content-type header, so httpd
> > will add it's default content-type header when the response is sent back.
>
> We have this in our spring controller...
>
> ...
> response.setContentType("text/html; charset=UTF-8");
> response.setCharacterEncoding("UTF-8");
> Writer writer= response.getWriter();
> if(bText) {
>         writer.append("<html><head><meta http-equiv=\"Content-Type\"
> content=\"text/html; charset=UTF-8\">\n</head>\n<body>\n");
> }
>
> writer.append(pageBody);
>
> if(bText) {
>         writer.append("\n</body></html>");
> }
> ...
>
> And the funny thing is that it seems to work... but only for straight
> tomcat. I will make a confession - I do mainly .net these days and my
> java (particularly web) is lacking in any real depth of understanding.
> So I am guessing from your comments that the default content type of
> tomcat is text/html? That is what we get with straight tomcat...
> In any case, if this code is wrong then can someone give me a
> suggestion to make it right?
> Thanks again.
> Anton

Sorry, on closer inspection it was working because tomcat doesn't seem
to send any contenttype at all... changing the default apache
contenttype to text/html seems to work without any nefarious
consequences.
Thanks,
Anton

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: problems with mod_jk modifying headers

Posted by Anton Melser <me...@gmail.com>.
On 04/07/07, Bill Barker <wb...@wilshire.com> wrote:
>
> "Anton Melser" <me...@gmail.com> wrote in message
> news:92d3a4950707020709p6dbc7b51md505ac0137b86199@mail.gmail.com...
> > (maybe a repost?)
> > Hi all,
> > We are running tomcat 5.5.23 on java 1.6.0 (suse 10.0 with addon java6
> > rpms for suse 10.1). These machines are load balanced behind an apache
> > 2.2.2 with mod_jk jakarta-tomcat-connectors-1.2.15 (both compiled from
> > sources). We have a page that is showing the html source instead of
> > the page on firefox2. The funny thing is that when the page is
> > accessed directly then the content type is text/html (and the page
> > shows correctly) but when coming through mod_jk, it is coming as
> > text/plain (and showing the source). This doesn't seem to bother
> > IE7...
> > Does anyone have any ideas?
>
> Well, the default content-type for httpd is text/plain, so if you have a
> controller servlet something like:
>
>    protected void doGet(HttpServletRequest req, HttpServletResponse res)
>      throws ServletException, IOException {
>         req.setAttribute("myBean", myBean);
>         RequestDispatcher rd =
> getServletContext().getRequestDispatcher("/WEB-INF/jsps/display.jsp");
>         rd.include(req, res);
>     }
>
> Then the JSP page will not be able to add it's content-type header, so httpd
> will add it's default content-type header when the response is sent back.

We have this in our spring controller...

...
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("UTF-8");
Writer writer= response.getWriter();
if(bText) {
	writer.append("<html><head><meta http-equiv=\"Content-Type\"
content=\"text/html; charset=UTF-8\">\n</head>\n<body>\n");
}

writer.append(pageBody);

if(bText) {
	writer.append("\n</body></html>");
}
...

And the funny thing is that it seems to work... but only for straight
tomcat. I will make a confession - I do mainly .net these days and my
java (particularly web) is lacking in any real depth of understanding.
So I am guessing from your comments that the default content type of
tomcat is text/html? That is what we get with straight tomcat...
In any case, if this code is wrong then can someone give me a
suggestion to make it right?
Thanks again.
Anton

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: problems with mod_jk modifying headers

Posted by Bill Barker <wb...@wilshire.com>.
"Anton Melser" <me...@gmail.com> wrote in message 
news:92d3a4950707020709p6dbc7b51md505ac0137b86199@mail.gmail.com...
> (maybe a repost?)
> Hi all,
> We are running tomcat 5.5.23 on java 1.6.0 (suse 10.0 with addon java6
> rpms for suse 10.1). These machines are load balanced behind an apache
> 2.2.2 with mod_jk jakarta-tomcat-connectors-1.2.15 (both compiled from
> sources). We have a page that is showing the html source instead of
> the page on firefox2. The funny thing is that when the page is
> accessed directly then the content type is text/html (and the page
> shows correctly) but when coming through mod_jk, it is coming as
> text/plain (and showing the source). This doesn't seem to bother
> IE7...
> Does anyone have any ideas?

Well, the default content-type for httpd is text/plain, so if you have a 
controller servlet something like:

   protected void doGet(HttpServletRequest req, HttpServletResponse res)
     throws ServletException, IOException {
        req.setAttribute("myBean", myBean);
        RequestDispatcher rd = 
getServletContext().getRequestDispatcher("/WEB-INF/jsps/display.jsp");
        rd.include(req, res);
    }

Then the JSP page will not be able to add it's content-type header, so httpd 
will add it's default content-type header when the response is sent back.

> Cheers
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: problems with mod_jk modifying headers

Posted by Titi Wangsa <bl...@gmail.com>.
i'm guessing you need to modify the mime type in you httpd.conf
to set .jsp as text/html
just my guess...
that's what i'd do if my system exhibited that symptom


On 7/2/07, Richard Kaye <R....@bham.ac.uk> wrote:
> I saw your first post and was interested.  I am running a
> very similar system with no problems (I take that back: there
> are problems, but not this problem).
> Q1. Is there something in your apache config file(s) to do
> with mimetypes that is messing things up?
> Q2. Are you working with strange charsets? Tomcat likes to
> add the "charset=..." parameter to the Content-Type header.
>
> > This doesn't seem to bother IE7...
> I know this, from experience. (sigh.) IE7 always know better
> than you do how you want a document displayed. If you choose
> to serve an example HTML source in a tutorial on HTML as
> text/plain so that the user can see the source, IE7 (and IE6)
> ignores the mimetype in the HTTP header that you carefully put
> there and displays something else just to spite you.
>
> Richard
>
>
> On Mon, 2007-07-02 at 16:09 +0200, Anton Melser wrote:
> > (maybe a repost?)
> > Hi all,
> > We are running tomcat 5.5.23 on java 1.6.0 (suse 10.0 with addon java6
> > rpms for suse 10.1). These machines are load balanced behind an apache
> > 2.2.2 with mod_jk jakarta-tomcat-connectors-1.2.15 (both compiled from
> > sources). We have a page that is showing the html source instead of
> > the page on firefox2. The funny thing is that when the page is
> > accessed directly then the content type is text/html (and the page
> > shows correctly) but when coming through mod_jk, it is coming as
> > text/plain (and showing the source). This doesn't seem to bother
> > IE7...
> > Does anyone have any ideas?
> > Cheers
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: problems with mod_jk modifying headers

Posted by Richard Kaye <R....@bham.ac.uk>.
I saw your first post and was interested.  I am running a 
very similar system with no problems (I take that back: there 
are problems, but not this problem).  
Q1. Is there something in your apache config file(s) to do 
with mimetypes that is messing things up?  
Q2. Are you working with strange charsets? Tomcat likes to 
add the "charset=..." parameter to the Content-Type header.

> This doesn't seem to bother IE7...
I know this, from experience. (sigh.) IE7 always know better 
than you do how you want a document displayed. If you choose 
to serve an example HTML source in a tutorial on HTML as 
text/plain so that the user can see the source, IE7 (and IE6) 
ignores the mimetype in the HTTP header that you carefully put 
there and displays something else just to spite you.

Richard


On Mon, 2007-07-02 at 16:09 +0200, Anton Melser wrote:
> (maybe a repost?)
> Hi all,
> We are running tomcat 5.5.23 on java 1.6.0 (suse 10.0 with addon java6
> rpms for suse 10.1). These machines are load balanced behind an apache
> 2.2.2 with mod_jk jakarta-tomcat-connectors-1.2.15 (both compiled from
> sources). We have a page that is showing the html source instead of
> the page on firefox2. The funny thing is that when the page is
> accessed directly then the content type is text/html (and the page
> shows correctly) but when coming through mod_jk, it is coming as
> text/plain (and showing the source). This doesn't seem to bother
> IE7...
> Does anyone have any ideas?
> Cheers
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org