You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by dfobox <df...@gmail.com> on 2009/04/25 01:46:16 UTC

Browser shows source of .jsp file. Why?

I have JSP-based website running on my own server and I want to move it to
hosting company. I've copied the files, they said they have enabled Tomcat
for me, but browser shows source of the pages, even of those which don't
have any script code inside - only properly formatted html. What could be a
problem? Thanks!
-- 
View this message in context: http://www.nabble.com/Browser-shows-source-of-.jsp-file.-Why--tp23226583p23226583.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Browser shows source of .jsp file. Why?

Posted by Andre-John Mas <aj...@sympatico.ca>.
What does try to open the parent folder show? Chances are, if they have
set up Tomcat, the files aren't being hosted with Tomcat. Another thing
worth checking is whether you have you WEB-INF/web.xml file deployed.

If they are cooperative ask them to show you how they have set things
up. The worst they can do is deny you the request.

André-John

On 24-Apr-2009, at 19:46, dfobox wrote:

>
> I have JSP-based website running on my own server and I want to move  
> it to
> hosting company. I've copied the files, they said they have enabled  
> Tomcat
> for me, but browser shows source of the pages, even of those which  
> don't
> have any script code inside - only properly formatted html. What  
> could be a
> problem? Thanks!
> -- 
> View this message in context: http://www.nabble.com/Browser-shows-source-of-.jsp-file.-Why--tp23226583p23226583.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


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


Re: Browser shows source of .jsp file. Why?

Posted by David Rush <da...@rushtone.com>.
Andre-John Mas wrote:
...
> 
> BTW since you are using a JSP, you should be able to specify the content
> type in the JSP:
> 
> <%@ page language="java" contentType="text/html; charset=UTF-8"
> pageEncoding="UTF-8"%>
> 

Actually I tried that first, adding it to all 3 .jsp files that were included (rather than a single forward), but it had no obvious effect on the problem.

David

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


Re: Browser shows source of .jsp file. Why?

Posted by Andre-John Mas <aj...@sympatico.ca>.
On 27-Apr-2009, at 22:05, David Rush wrote:

> Andre-John:
>
> Actually it was the original poster who was using a hosting  
> company.  I'm using machines that I have full control of.
>
> My problem was resolved by calling setContentType("text/html") in  
> the controller servlet before it used include() to send control to  
> some .jsp files.

Ah ok, I hadn't paid attention to the issue change.

BTW since you are using a JSP, you should be able to specify the  
content type in the JSP:

<%@ page language="java" contentType="text/html; charset=UTF-8"  
pageEncoding="UTF-8"%>

André-John
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Browser shows source of .jsp file. Why?

Posted by David Rush <da...@rushtone.com>.
Andre-John:

Actually it was the original poster who was using a hosting company.  I'm using machines that I have full control of.

My problem was resolved by calling setContentType("text/html") in the controller servlet before it used include() to send control to some .jsp files.

David

Andre-John Mas wrote:
> 
> On 27-Apr-2009, at 09:04, Pid wrote:
> 
>> David Rush wrote:
>>> I checked my web.xml, and found no mime-mapping elements at all.  I
>>> tried adding one explicitly mapping the jsp extension to text/html,
>>> but it had no effect.  I'm still getting HTML markup in the browser
>>> window with Firefox.
>>>
>>> David
>>
>> Ignore that, it's a red herring, you don't need to add mime-mappings.
>>
>> You say the problem occurs 'sometimes' with Firefox, can you elaborate
>> on which times and if there's a commonality between these requests?
>>
>>
>> The fault is usually in the AJP mapping you've configured.  Are you
>> using mod_jk, and if so, what is the config?
>>
>> Also, try splitting your HTTP docroot and Tomcat webapps folders (a
>> correct mapping will mean it still works properly).  If the JSPs are in
>> another location than the HTTP docs, they can't be served as raw HTML,
>> by accident.
> 
> He indicated in an earlier post that it was his hosting provider who
> deployed
> his application.
> 
> David, have you been able to find out how your hosting company deployed
> your
> application? Also, what is there "server" header value in the response
> header?
> 
> If your web application is properly deployed then there is no reason your
> web browser should see the raw JSP. This is because if everything works
> correctly Tomcat will have interpreted the JSP and returned you the result
> of that.
> 
> If in doubt, try to simulate the set up on your machine. Even if it doesn't
> solve the hosting provider side of things, it should help you gain a better
> understanding of how things work.
> 
> André-John
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

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


Re: Browser shows source of .jsp file. Why?

Posted by Andre-John Mas <aj...@sympatico.ca>.
On 27-Apr-2009, at 09:04, Pid wrote:

> David Rush wrote:
>> I checked my web.xml, and found no mime-mapping elements at all.  I  
>> tried adding one explicitly mapping the jsp extension to text/html,  
>> but it had no effect.  I'm still getting HTML markup in the browser  
>> window with Firefox.
>>
>> David
>
> Ignore that, it's a red herring, you don't need to add mime-mappings.
>
> You say the problem occurs 'sometimes' with Firefox, can you elaborate
> on which times and if there's a commonality between these requests?
>
>
> The fault is usually in the AJP mapping you've configured.  Are you
> using mod_jk, and if so, what is the config?
>
> Also, try splitting your HTTP docroot and Tomcat webapps folders (a
> correct mapping will mean it still works properly).  If the JSPs are  
> in
> another location than the HTTP docs, they can't be served as raw HTML,
> by accident.

He indicated in an earlier post that it was his hosting provider who  
deployed
his application.

David, have you been able to find out how your hosting company  
deployed your
application? Also, what is there "server" header value in the response  
header?

If your web application is properly deployed then there is no reason  
your
web browser should see the raw JSP. This is because if everything works
correctly Tomcat will have interpreted the JSP and returned you the  
result
of that.

If in doubt, try to simulate the set up on your machine. Even if it  
doesn't
solve the hosting provider side of things, it should help you gain a  
better
understanding of how things work.

André-John
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Browser shows source of .jsp file. Why?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David,

On 4/27/2009 10:11 AM, David Rush wrote:
> The controller servlet is using three
> 
> rd = req.getRequestDispatcher("something.jsp"); 
> rd.include(req,resp);
> 
> blocks (with essentially header, main content, and footer .jsp files)
> to assemble the final output page.  Initially there was no
> req.setContentType() at all.  Once I added
> req.setContentType("text/html") it appears to have resolved the
> problem.

You shouldn't have had to do this. What file is calling the includes? If
it's just a servlet, then you almost definitely have to provide a
Content-Type header, because the "include" files aren't going to (not
are they permitted to, according to the servlet spec). If it came from a
JSP, the JSP's default Content-Type is text/html, and something is wrong.

It should be noted that both Google Chrome and Mozilla Firefox are
behaving correctly: MSIE violates the HTTP specification which states
that the Content-Type sent by the server (text/plain in your case) may
not be overridden (S7.2.1: "If and only if the media type is not given
by a Content-Type field, the recipient MAY attempt to guess the media
type[...]"). It's only a (stupid) coincidence that your servlet works in
MSIE.

You may want to inspect other servlets for the same type of defect.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkn/TB8ACgkQ9CaO5/Lv0PB5LgCgwKkczCMW1pI5dMpPOGVMEKeQ
Ic4AnRz4fraMcHbMS40FpJPvkZMgLE7F
=zbb2
-----END PGP SIGNATURE-----

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


Re: Browser shows source of .jsp file. Why?

Posted by David Rush <da...@rushtone.com>.
The URL http://myserver/Construction/ (with trailing slash) yields the same results as http://myserver/Construction (without trailing slash).

I think I may have solved the problem.  I didn't write this webapp, but have inherited it so I'm still learning it's inner workings.

The controller servlet is using three 

rd = req.getRequestDispatcher("something.jsp");
rd.include(req,resp);

blocks (with essentially header, main content, and footer .jsp files) to assemble the final output page.  Initially there was no req.setContentType() at all.  Once I added req.setContentType("text/html") it appears to have resolved the problem.

w00t.

I've used rd.forward() and don't think I ever had to use setContentType(), but have never used rd.include() in my own webapps.  I guess since include() adds only a portion of a page, you have to treat the whole deal more like a servlet and explicitly set the content-type.

Thanks for the help.

David

Pid wrote:
> David Rush wrote:
>> Pid:
>>
>> Yes, I've removed the explicit mapping.
>>
>> "Sometimes" because when I use the URL http://myserver:8080/Construction (direct to Tomcat listening port) it works fine (HTML is rendered).
>> When I use http://myserver/Construction (via reverse proxy forwarding through Apache httpd) it fails (I get HTML markup in the browser window).
> 
> What about "http://myserver/Construction/" (note extra slash)
> 
>> When I use http://myserver/Construction/index.html (where index.html is mapped in web.xml to a controller servlet and index.html is my sole welcome-file) it works fine.
>>
>> I'm not using AJP.  I'm just using straight reverse-proxy style HTTP forwarding with mod_proxy, with this snippet from my httpd.conf file:
> 
> (Sorry, I spotted that after I'd sent the reply.)
> 
> 
>> ...
>> ProxyPass        /Construction http://localhost:8080/Construction
>> ProxyPassReverse /Construction http://localhost:8080/Construction
>> ...
>>
>> My Apache httpd docroot has always been separate and distinct from my Tomcat webapps directory.
> 
> Looking at your headers again, I see that Tomcat is trying to serve the
> result as plain html.  What happens if you use "index.jsp" as the sole
> welcome file (and map that to the controller, obviously)?
> 
> Check "index.jsp" is included in the DirectoryIndex in HTTPD.
> 
> 
> p
> 
> 
> 
>> David
>>
>> Pid wrote:
>>> David Rush wrote:
>>>> I checked my web.xml, and found no mime-mapping elements at all.  I tried adding one explicitly mapping the jsp extension to text/html, but it had no effect.  I'm still getting HTML markup in the browser window with Firefox.
>>>>
>>>> David
>>> Ignore that, it's a red herring, you don't need to add mime-mappings.
>>>
>>> You say the problem occurs 'sometimes' with Firefox, can you elaborate
>>> on which times and if there's a commonality between these requests?
>>>
>>>
>>> The fault is usually in the AJP mapping you've configured.  Are you
>>> using mod_jk, and if so, what is the config?
>>>
>>> Also, try splitting your HTTP docroot and Tomcat webapps folders (a
>>> correct mapping will mean it still works properly).  If the JSPs are in
>>> another location than the HTTP docs, they can't be served as raw HTML,
>>> by accident.
>>>
>>>
>>> p
>>>
>>>
>>>
>>>
>>>
>>>> Martin Gainty wrote:
>>>>> David
>>>>>
>>>>> did you check your mime-mapping in your web.xml 
>>>>> perchance are you mapping jsp to text/plain?
>>>>> is any other extension mapped to text/plain?
>>>>>
>>>>>     <mime-mapping>
>>>>>         <extension>jsp</extension>
>>>>>         <mime-type>text/plain</mime-type>
>>>>>     </mime-mapping>
>>>>>
>>>>> Martin 
>>>>> ______________________________________________ 
>>>>> Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
>>>>> This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
>>>>> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>>>>> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> Date: Sat, 25 Apr 2009 05:46:03 -0600
>>>>>> From: david@rushtone.com
>>>>>> To: users@tomcat.apache.org
>>>>>> Subject: Re: Browser shows source of .jsp file. Why?
>>>>>>
>>>>>> I'm having the same problem, where markup is sometimes appearing in the browser window instead of the rendered HTML.
>>>>>>
>>>>>> I'm using my own server (MS Windows Server 2003), with Tomcat 6.0.18 behind a reverse proxy on Apache 2.2.11.
>>>>>>
>>>>>> When I access one of my webapps via Tomcat's port (http://myserver:8080/Construction/) it works fine.  When I access it via the reverse proxy (http://myserver/Construction) using Firefox 3.0.9 I see the HTML markup displayed in the browser's window.  When I access the webapp via IE either way, it works fine.  Google Chrome produces the same results as Firefox.
>>>>>>
>>>>>> Via Live HTTP Headers, when I access through the reverse proxy I see:
>>>>>>
>>>>>> HTTP/1.x 200 OK
>>>>>> Date: Sat, 25 Apr 2009 11:39:11 GMT
>>>>>> Server: Apache-Coyote/1.1
>>>>>> Keep-Alive: timeout=5, max=100
>>>>>> Connection: Keep-Alive
>>>>>> Transfer-Encoding: chunked
>>>>>> Content-Type: text/plain
>>>>>>
>>>>>> I suspect the "Content-Type: text/plain" is a clue.  Straight to Tomcat I see:
>>>>>>
>>>>>> HTTP/1.x 200 OK
>>>>>> Server: Apache-Coyote/1.1
>>>>>> Set-Cookie: JSESSIONID=53C3EC973BB365AAF92A1EC66F03271A; Path=/Construction
>>>>>> Transfer-Encoding: chunked
>>>>>> Date: Sat, 25 Apr 2009 11:37:06 GMT
>>>>>>
>>>>>> No "Content-Type" produced at all.
>>>>>>
>>>>>> When I access it with Firefox via the Apache reverse proxy via the URL http://myserver/Construction/index.html (which is just mapped in web.xml to the controlling servlet, and my welcome-file is index.html), the webapp displays correctly, and the headers say:
>>>>>>
>>>>>> HTTP/1.x 200 OK
>>>>>> Date: Sat, 25 Apr 2009 11:42:27 GMT
>>>>>> Server: Apache-Coyote/1.1
>>>>>> Keep-Alive: timeout=5, max=100
>>>>>> Connection: Keep-Alive
>>>>>> Transfer-Encoding: chunked
>>>>>> Content-Type: text/html
>>>>>>
>>>>>> I have 3 different webapps, but I only see the problem with one of them.
>>>>>>
>>>>>> My reverse proxy configuration includes:
>>>>>>
>>>>>> ProxyPass        /Construction http://localhost:8080/Construction
>>>>>> ProxyPassReverse /Construction http://localhost:8080/Construction
>>>>>>
>>>>>> David
>>>>>>
>>>>>> dfobox wrote:
>>>>>>> I have JSP-based website running on my own server and I want to move it to
>>>>>>> hosting company. I've copied the files, they said they have enabled Tomcat
>>>>>>> for me, but browser shows source of the pages, even of those which don't
>>>>>>> have any script code inside - only properly formatted html. What could be a
>>>>>>> problem? Thanks!
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>>
>>>>> _________________________________________________________________
>>>>> Rediscover Hotmail®: Get e-mail storage that grows with you. 
>>>>> http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

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


RE: Browser shows source of .jsp file. Why?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: David Rush [mailto:david@rushtone.com]
> Subject: Re: Browser shows source of .jsp file. Why?
> 
> It also appears that Tomcat (rather than Apache httpd) is initially
> responding to my http://myserver/Construction URL with a 302 (Moved
> Temporarily) and a suggestion that the browser try
> http://myserver/Construction/ (with trailing slash), as it should.

I think what pid was suggesting is that you fix your ProxyPass settings to include the trailing slash.  After the 302, the URL with the slash won't match what you have configured, and it will be served by httpd rather than being sent on to Tomcat.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: Browser shows source of .jsp file. Why?

Posted by David Rush <da...@rushtone.com>.
Martin:

I'm aware that Apache httpd will do that for its pages.  But in my case it appears the reverse proxy forwarding is happening before httpd would try to add the index.html, indicated by Tomcat access log showing a request to /Construction/ without the index.html.

It also appears that Tomcat (rather than Apache httpd) is initially responding to my http://myserver/Construction URL with a 302 (Moved Temporarily) and a suggestion that the browser try http://myserver/Construction/ (with trailing slash), as it should.  I say Tomcat's doing that rather than Apache httpd since the 302 response says it's from Apache-Coyote/1.1 rather than Apache/2.2.11.

Anyway, it appears that adding the setContentType("text/html") before the include() calls has fixed my problem.

Thanks for your help.

David

Martin Gainty wrote:
> David
> 
> Apache will automaticly append index.html to requested folder via
> http://httpd.apache.org/docs/1.3/mod/mod_dir.html#directoryindex
> 
> Does this help?
> Martin 
> ______________________________________________ 
> Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
> This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> 
> 
> 
> 
> 
> 
>> Date: Mon, 27 Apr 2009 14:46:25 +0100
>> From: p@pidster.com
>> To: users@tomcat.apache.org
>> Subject: Re: Browser shows source of .jsp file. Why?
>>
>> David Rush wrote:
>>> Pid:
>>>
>>> Yes, I've removed the explicit mapping.
>>>
>>> "Sometimes" because when I use the URL http://myserver:8080/Construction (direct to Tomcat listening port) it works fine (HTML is rendered).
>>> When I use http://myserver/Construction (via reverse proxy forwarding through Apache httpd) it fails (I get HTML markup in the browser window).
>> What about "http://myserver/Construction/" (note extra slash)
>>
>>> When I use http://myserver/Construction/index.html (where index.html is mapped in web.xml to a controller servlet and index.html is my sole welcome-file) it works fine.
>>>
>>> I'm not using AJP.  I'm just using straight reverse-proxy style HTTP forwarding with mod_proxy, with this snippet from my httpd.conf file:
>> (Sorry, I spotted that after I'd sent the reply.)
>>
>>
>>> ...
>>> ProxyPass        /Construction http://localhost:8080/Construction
>>> ProxyPassReverse /Construction http://localhost:8080/Construction
>>> ...
>>>
>>> My Apache httpd docroot has always been separate and distinct from my Tomcat webapps directory.
>> Looking at your headers again, I see that Tomcat is trying to serve the
>> result as plain html.  What happens if you use "index.jsp" as the sole
>> welcome file (and map that to the controller, obviously)?
>>
>> Check "index.jsp" is included in the DirectoryIndex in HTTPD.
>>
>>
>> p
>>
>>
>>
>>> David
>>>
>>> Pid wrote:
>>>> David Rush wrote:
>>>>> I checked my web.xml, and found no mime-mapping elements at all.  I tried adding one explicitly mapping the jsp extension to text/html, but it had no effect.  I'm still getting HTML markup in the browser window with Firefox.
>>>>>
>>>>> David
>>>> Ignore that, it's a red herring, you don't need to add mime-mappings.
>>>>
>>>> You say the problem occurs 'sometimes' with Firefox, can you elaborate
>>>> on which times and if there's a commonality between these requests?
>>>>
>>>>
>>>> The fault is usually in the AJP mapping you've configured.  Are you
>>>> using mod_jk, and if so, what is the config?
>>>>
>>>> Also, try splitting your HTTP docroot and Tomcat webapps folders (a
>>>> correct mapping will mean it still works properly).  If the JSPs are in
>>>> another location than the HTTP docs, they can't be served as raw HTML,
>>>> by accident.
>>>>
>>>>
>>>> p
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Martin Gainty wrote:
>>>>>> David
>>>>>>
>>>>>> did you check your mime-mapping in your web.xml 
>>>>>> perchance are you mapping jsp to text/plain?
>>>>>> is any other extension mapped to text/plain?
>>>>>>
>>>>>>     <mime-mapping>
>>>>>>         <extension>jsp</extension>
>>>>>>         <mime-type>text/plain</mime-type>
>>>>>>     </mime-mapping>
>>>>>>
>>>>>> Martin 
>>>>>> ______________________________________________ 
>>>>>> Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
>>>>>> This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
>>>>>> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>>>>>> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Date: Sat, 25 Apr 2009 05:46:03 -0600
>>>>>>> From: david@rushtone.com
>>>>>>> To: users@tomcat.apache.org
>>>>>>> Subject: Re: Browser shows source of .jsp file. Why?
>>>>>>>
>>>>>>> I'm having the same problem, where markup is sometimes appearing in the browser window instead of the rendered HTML.
>>>>>>>
>>>>>>> I'm using my own server (MS Windows Server 2003), with Tomcat 6.0.18 behind a reverse proxy on Apache 2.2.11.
>>>>>>>
>>>>>>> When I access one of my webapps via Tomcat's port (http://myserver:8080/Construction/) it works fine.  When I access it via the reverse proxy (http://myserver/Construction) using Firefox 3.0.9 I see the HTML markup displayed in the browser's window.  When I access the webapp via IE either way, it works fine.  Google Chrome produces the same results as Firefox.
>>>>>>>
>>>>>>> Via Live HTTP Headers, when I access through the reverse proxy I see:
>>>>>>>
>>>>>>> HTTP/1.x 200 OK
>>>>>>> Date: Sat, 25 Apr 2009 11:39:11 GMT
>>>>>>> Server: Apache-Coyote/1.1
>>>>>>> Keep-Alive: timeout=5, max=100
>>>>>>> Connection: Keep-Alive
>>>>>>> Transfer-Encoding: chunked
>>>>>>> Content-Type: text/plain
>>>>>>>
>>>>>>> I suspect the "Content-Type: text/plain" is a clue.  Straight to Tomcat I see:
>>>>>>>
>>>>>>> HTTP/1.x 200 OK
>>>>>>> Server: Apache-Coyote/1.1
>>>>>>> Set-Cookie: JSESSIONID=53C3EC973BB365AAF92A1EC66F03271A; Path=/Construction
>>>>>>> Transfer-Encoding: chunked
>>>>>>> Date: Sat, 25 Apr 2009 11:37:06 GMT
>>>>>>>
>>>>>>> No "Content-Type" produced at all.
>>>>>>>
>>>>>>> When I access it with Firefox via the Apache reverse proxy via the URL http://myserver/Construction/index.html (which is just mapped in web.xml to the controlling servlet, and my welcome-file is index.html), the webapp displays correctly, and the headers say:
>>>>>>>
>>>>>>> HTTP/1.x 200 OK
>>>>>>> Date: Sat, 25 Apr 2009 11:42:27 GMT
>>>>>>> Server: Apache-Coyote/1.1
>>>>>>> Keep-Alive: timeout=5, max=100
>>>>>>> Connection: Keep-Alive
>>>>>>> Transfer-Encoding: chunked
>>>>>>> Content-Type: text/html
>>>>>>>
>>>>>>> I have 3 different webapps, but I only see the problem with one of them.
>>>>>>>
>>>>>>> My reverse proxy configuration includes:
>>>>>>>
>>>>>>> ProxyPass        /Construction http://localhost:8080/Construction
>>>>>>> ProxyPassReverse /Construction http://localhost:8080/Construction
>>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>> dfobox wrote:
>>>>>>>> I have JSP-based website running on my own server and I want to move it to
>>>>>>>> hosting company. I've copied the files, they said they have enabled Tomcat
>>>>>>>> for me, but browser shows source of the pages, even of those which don't
>>>>>>>> have any script code inside - only properly formatted html. What could be a
>>>>>>>> problem? Thanks!
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>>>
>>>>>> _________________________________________________________________
>>>>>> Rediscover Hotmail®: Get e-mail storage that grows with you. 
>>>>>> http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> 
> _________________________________________________________________
> Windows Live™ SkyDrive™: Get 25 GB of free online storage.  
> http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_skydrive_042009

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


RE: Browser shows source of .jsp file. Why?

Posted by Martin Gainty <mg...@hotmail.com>.
David

Apache will automaticly append index.html to requested folder via
http://httpd.apache.org/docs/1.3/mod/mod_dir.html#directoryindex

Does this help?
Martin 
______________________________________________ 
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.






> Date: Mon, 27 Apr 2009 14:46:25 +0100
> From: p@pidster.com
> To: users@tomcat.apache.org
> Subject: Re: Browser shows source of .jsp file. Why?
> 
> David Rush wrote:
> > Pid:
> > 
> > Yes, I've removed the explicit mapping.
> > 
> > "Sometimes" because when I use the URL http://myserver:8080/Construction (direct to Tomcat listening port) it works fine (HTML is rendered).
> > When I use http://myserver/Construction (via reverse proxy forwarding through Apache httpd) it fails (I get HTML markup in the browser window).
> 
> What about "http://myserver/Construction/" (note extra slash)
> 
> > When I use http://myserver/Construction/index.html (where index.html is mapped in web.xml to a controller servlet and index.html is my sole welcome-file) it works fine.
> > 
> > I'm not using AJP.  I'm just using straight reverse-proxy style HTTP forwarding with mod_proxy, with this snippet from my httpd.conf file:
> 
> (Sorry, I spotted that after I'd sent the reply.)
> 
> 
> > ...
> > ProxyPass        /Construction http://localhost:8080/Construction
> > ProxyPassReverse /Construction http://localhost:8080/Construction
> > ...
> > 
> > My Apache httpd docroot has always been separate and distinct from my Tomcat webapps directory.
> 
> Looking at your headers again, I see that Tomcat is trying to serve the
> result as plain html.  What happens if you use "index.jsp" as the sole
> welcome file (and map that to the controller, obviously)?
> 
> Check "index.jsp" is included in the DirectoryIndex in HTTPD.
> 
> 
> p
> 
> 
> 
> > David
> > 
> > Pid wrote:
> >> David Rush wrote:
> >>> I checked my web.xml, and found no mime-mapping elements at all.  I tried adding one explicitly mapping the jsp extension to text/html, but it had no effect.  I'm still getting HTML markup in the browser window with Firefox.
> >>>
> >>> David
> >> Ignore that, it's a red herring, you don't need to add mime-mappings.
> >>
> >> You say the problem occurs 'sometimes' with Firefox, can you elaborate
> >> on which times and if there's a commonality between these requests?
> >>
> >>
> >> The fault is usually in the AJP mapping you've configured.  Are you
> >> using mod_jk, and if so, what is the config?
> >>
> >> Also, try splitting your HTTP docroot and Tomcat webapps folders (a
> >> correct mapping will mean it still works properly).  If the JSPs are in
> >> another location than the HTTP docs, they can't be served as raw HTML,
> >> by accident.
> >>
> >>
> >> p
> >>
> >>
> >>
> >>
> >>
> >>> Martin Gainty wrote:
> >>>> David
> >>>>
> >>>> did you check your mime-mapping in your web.xml 
> >>>> perchance are you mapping jsp to text/plain?
> >>>> is any other extension mapped to text/plain?
> >>>>
> >>>>     <mime-mapping>
> >>>>         <extension>jsp</extension>
> >>>>         <mime-type>text/plain</mime-type>
> >>>>     </mime-mapping>
> >>>>
> >>>> Martin 
> >>>> ______________________________________________ 
> >>>> Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
> >>>> This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
> >>>> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> >>>> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>> Date: Sat, 25 Apr 2009 05:46:03 -0600
> >>>>> From: david@rushtone.com
> >>>>> To: users@tomcat.apache.org
> >>>>> Subject: Re: Browser shows source of .jsp file. Why?
> >>>>>
> >>>>> I'm having the same problem, where markup is sometimes appearing in the browser window instead of the rendered HTML.
> >>>>>
> >>>>> I'm using my own server (MS Windows Server 2003), with Tomcat 6.0.18 behind a reverse proxy on Apache 2.2.11.
> >>>>>
> >>>>> When I access one of my webapps via Tomcat's port (http://myserver:8080/Construction/) it works fine.  When I access it via the reverse proxy (http://myserver/Construction) using Firefox 3.0.9 I see the HTML markup displayed in the browser's window.  When I access the webapp via IE either way, it works fine.  Google Chrome produces the same results as Firefox.
> >>>>>
> >>>>> Via Live HTTP Headers, when I access through the reverse proxy I see:
> >>>>>
> >>>>> HTTP/1.x 200 OK
> >>>>> Date: Sat, 25 Apr 2009 11:39:11 GMT
> >>>>> Server: Apache-Coyote/1.1
> >>>>> Keep-Alive: timeout=5, max=100
> >>>>> Connection: Keep-Alive
> >>>>> Transfer-Encoding: chunked
> >>>>> Content-Type: text/plain
> >>>>>
> >>>>> I suspect the "Content-Type: text/plain" is a clue.  Straight to Tomcat I see:
> >>>>>
> >>>>> HTTP/1.x 200 OK
> >>>>> Server: Apache-Coyote/1.1
> >>>>> Set-Cookie: JSESSIONID=53C3EC973BB365AAF92A1EC66F03271A; Path=/Construction
> >>>>> Transfer-Encoding: chunked
> >>>>> Date: Sat, 25 Apr 2009 11:37:06 GMT
> >>>>>
> >>>>> No "Content-Type" produced at all.
> >>>>>
> >>>>> When I access it with Firefox via the Apache reverse proxy via the URL http://myserver/Construction/index.html (which is just mapped in web.xml to the controlling servlet, and my welcome-file is index.html), the webapp displays correctly, and the headers say:
> >>>>>
> >>>>> HTTP/1.x 200 OK
> >>>>> Date: Sat, 25 Apr 2009 11:42:27 GMT
> >>>>> Server: Apache-Coyote/1.1
> >>>>> Keep-Alive: timeout=5, max=100
> >>>>> Connection: Keep-Alive
> >>>>> Transfer-Encoding: chunked
> >>>>> Content-Type: text/html
> >>>>>
> >>>>> I have 3 different webapps, but I only see the problem with one of them.
> >>>>>
> >>>>> My reverse proxy configuration includes:
> >>>>>
> >>>>> ProxyPass        /Construction http://localhost:8080/Construction
> >>>>> ProxyPassReverse /Construction http://localhost:8080/Construction
> >>>>>
> >>>>> David
> >>>>>
> >>>>> dfobox wrote:
> >>>>>> I have JSP-based website running on my own server and I want to move it to
> >>>>>> hosting company. I've copied the files, they said they have enabled Tomcat
> >>>>>> for me, but browser shows source of the pages, even of those which don't
> >>>>>> have any script code inside - only properly formatted html. What could be a
> >>>>>> problem? Thanks!
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >>>>> For additional commands, e-mail: users-help@tomcat.apache.org
> >>>>>
> >>>> _________________________________________________________________
> >>>> Rediscover Hotmail®: Get e-mail storage that grows with you. 
> >>>> http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >>> For additional commands, e-mail: users-help@tomcat.apache.org
> >>>
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >>
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

_________________________________________________________________
Windows Live™ SkyDrive™: Get 25 GB of free online storage.  
http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_skydrive_042009

Re: Browser shows source of .jsp file. Why?

Posted by Pid <p...@pidster.com>.
David Rush wrote:
> Pid:
> 
> Yes, I've removed the explicit mapping.
> 
> "Sometimes" because when I use the URL http://myserver:8080/Construction (direct to Tomcat listening port) it works fine (HTML is rendered).
> When I use http://myserver/Construction (via reverse proxy forwarding through Apache httpd) it fails (I get HTML markup in the browser window).

What about "http://myserver/Construction/" (note extra slash)

> When I use http://myserver/Construction/index.html (where index.html is mapped in web.xml to a controller servlet and index.html is my sole welcome-file) it works fine.
> 
> I'm not using AJP.  I'm just using straight reverse-proxy style HTTP forwarding with mod_proxy, with this snippet from my httpd.conf file:

(Sorry, I spotted that after I'd sent the reply.)


> ...
> ProxyPass        /Construction http://localhost:8080/Construction
> ProxyPassReverse /Construction http://localhost:8080/Construction
> ...
> 
> My Apache httpd docroot has always been separate and distinct from my Tomcat webapps directory.

Looking at your headers again, I see that Tomcat is trying to serve the
result as plain html.  What happens if you use "index.jsp" as the sole
welcome file (and map that to the controller, obviously)?

Check "index.jsp" is included in the DirectoryIndex in HTTPD.


p



> David
> 
> Pid wrote:
>> David Rush wrote:
>>> I checked my web.xml, and found no mime-mapping elements at all.  I tried adding one explicitly mapping the jsp extension to text/html, but it had no effect.  I'm still getting HTML markup in the browser window with Firefox.
>>>
>>> David
>> Ignore that, it's a red herring, you don't need to add mime-mappings.
>>
>> You say the problem occurs 'sometimes' with Firefox, can you elaborate
>> on which times and if there's a commonality between these requests?
>>
>>
>> The fault is usually in the AJP mapping you've configured.  Are you
>> using mod_jk, and if so, what is the config?
>>
>> Also, try splitting your HTTP docroot and Tomcat webapps folders (a
>> correct mapping will mean it still works properly).  If the JSPs are in
>> another location than the HTTP docs, they can't be served as raw HTML,
>> by accident.
>>
>>
>> p
>>
>>
>>
>>
>>
>>> Martin Gainty wrote:
>>>> David
>>>>
>>>> did you check your mime-mapping in your web.xml 
>>>> perchance are you mapping jsp to text/plain?
>>>> is any other extension mapped to text/plain?
>>>>
>>>>     <mime-mapping>
>>>>         <extension>jsp</extension>
>>>>         <mime-type>text/plain</mime-type>
>>>>     </mime-mapping>
>>>>
>>>> Martin 
>>>> ______________________________________________ 
>>>> Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
>>>> This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
>>>> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>>>> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Date: Sat, 25 Apr 2009 05:46:03 -0600
>>>>> From: david@rushtone.com
>>>>> To: users@tomcat.apache.org
>>>>> Subject: Re: Browser shows source of .jsp file. Why?
>>>>>
>>>>> I'm having the same problem, where markup is sometimes appearing in the browser window instead of the rendered HTML.
>>>>>
>>>>> I'm using my own server (MS Windows Server 2003), with Tomcat 6.0.18 behind a reverse proxy on Apache 2.2.11.
>>>>>
>>>>> When I access one of my webapps via Tomcat's port (http://myserver:8080/Construction/) it works fine.  When I access it via the reverse proxy (http://myserver/Construction) using Firefox 3.0.9 I see the HTML markup displayed in the browser's window.  When I access the webapp via IE either way, it works fine.  Google Chrome produces the same results as Firefox.
>>>>>
>>>>> Via Live HTTP Headers, when I access through the reverse proxy I see:
>>>>>
>>>>> HTTP/1.x 200 OK
>>>>> Date: Sat, 25 Apr 2009 11:39:11 GMT
>>>>> Server: Apache-Coyote/1.1
>>>>> Keep-Alive: timeout=5, max=100
>>>>> Connection: Keep-Alive
>>>>> Transfer-Encoding: chunked
>>>>> Content-Type: text/plain
>>>>>
>>>>> I suspect the "Content-Type: text/plain" is a clue.  Straight to Tomcat I see:
>>>>>
>>>>> HTTP/1.x 200 OK
>>>>> Server: Apache-Coyote/1.1
>>>>> Set-Cookie: JSESSIONID=53C3EC973BB365AAF92A1EC66F03271A; Path=/Construction
>>>>> Transfer-Encoding: chunked
>>>>> Date: Sat, 25 Apr 2009 11:37:06 GMT
>>>>>
>>>>> No "Content-Type" produced at all.
>>>>>
>>>>> When I access it with Firefox via the Apache reverse proxy via the URL http://myserver/Construction/index.html (which is just mapped in web.xml to the controlling servlet, and my welcome-file is index.html), the webapp displays correctly, and the headers say:
>>>>>
>>>>> HTTP/1.x 200 OK
>>>>> Date: Sat, 25 Apr 2009 11:42:27 GMT
>>>>> Server: Apache-Coyote/1.1
>>>>> Keep-Alive: timeout=5, max=100
>>>>> Connection: Keep-Alive
>>>>> Transfer-Encoding: chunked
>>>>> Content-Type: text/html
>>>>>
>>>>> I have 3 different webapps, but I only see the problem with one of them.
>>>>>
>>>>> My reverse proxy configuration includes:
>>>>>
>>>>> ProxyPass        /Construction http://localhost:8080/Construction
>>>>> ProxyPassReverse /Construction http://localhost:8080/Construction
>>>>>
>>>>> David
>>>>>
>>>>> dfobox wrote:
>>>>>> I have JSP-based website running on my own server and I want to move it to
>>>>>> hosting company. I've copied the files, they said they have enabled Tomcat
>>>>>> for me, but browser shows source of the pages, even of those which don't
>>>>>> have any script code inside - only properly formatted html. What could be a
>>>>>> problem? Thanks!
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>
>>>> _________________________________________________________________
>>>> Rediscover Hotmail®: Get e-mail storage that grows with you. 
>>>> http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


Re: Browser shows source of .jsp file. Why?

Posted by David Rush <da...@rushtone.com>.
Pid:

Yes, I've removed the explicit mapping.

"Sometimes" because when I use the URL http://myserver:8080/Construction (direct to Tomcat listening port) it works fine (HTML is rendered).
When I use http://myserver/Construction (via reverse proxy forwarding through Apache httpd) it fails (I get HTML markup in the browser window).
When I use http://myserver/Construction/index.html (where index.html is mapped in web.xml to a controller servlet and index.html is my sole welcome-file) it works fine.

I'm not using AJP.  I'm just using straight reverse-proxy style HTTP forwarding with mod_proxy, with this snippet from my httpd.conf file:

...
ProxyPass        /Construction http://localhost:8080/Construction
ProxyPassReverse /Construction http://localhost:8080/Construction
...

My Apache httpd docroot has always been separate and distinct from my Tomcat webapps directory.

David

Pid wrote:
> David Rush wrote:
>> I checked my web.xml, and found no mime-mapping elements at all.  I tried adding one explicitly mapping the jsp extension to text/html, but it had no effect.  I'm still getting HTML markup in the browser window with Firefox.
>>
>> David
> 
> Ignore that, it's a red herring, you don't need to add mime-mappings.
> 
> You say the problem occurs 'sometimes' with Firefox, can you elaborate
> on which times and if there's a commonality between these requests?
> 
> 
> The fault is usually in the AJP mapping you've configured.  Are you
> using mod_jk, and if so, what is the config?
> 
> Also, try splitting your HTTP docroot and Tomcat webapps folders (a
> correct mapping will mean it still works properly).  If the JSPs are in
> another location than the HTTP docs, they can't be served as raw HTML,
> by accident.
> 
> 
> p
> 
> 
> 
> 
> 
>> Martin Gainty wrote:
>>> David
>>>
>>> did you check your mime-mapping in your web.xml 
>>> perchance are you mapping jsp to text/plain?
>>> is any other extension mapped to text/plain?
>>>
>>>     <mime-mapping>
>>>         <extension>jsp</extension>
>>>         <mime-type>text/plain</mime-type>
>>>     </mime-mapping>
>>>
>>> Martin 
>>> ______________________________________________ 
>>> Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
>>> This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
>>> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>>> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
>>>
>>>
>>>
>>>
>>>
>>>
>>>> Date: Sat, 25 Apr 2009 05:46:03 -0600
>>>> From: david@rushtone.com
>>>> To: users@tomcat.apache.org
>>>> Subject: Re: Browser shows source of .jsp file. Why?
>>>>
>>>> I'm having the same problem, where markup is sometimes appearing in the browser window instead of the rendered HTML.
>>>>
>>>> I'm using my own server (MS Windows Server 2003), with Tomcat 6.0.18 behind a reverse proxy on Apache 2.2.11.
>>>>
>>>> When I access one of my webapps via Tomcat's port (http://myserver:8080/Construction/) it works fine.  When I access it via the reverse proxy (http://myserver/Construction) using Firefox 3.0.9 I see the HTML markup displayed in the browser's window.  When I access the webapp via IE either way, it works fine.  Google Chrome produces the same results as Firefox.
>>>>
>>>> Via Live HTTP Headers, when I access through the reverse proxy I see:
>>>>
>>>> HTTP/1.x 200 OK
>>>> Date: Sat, 25 Apr 2009 11:39:11 GMT
>>>> Server: Apache-Coyote/1.1
>>>> Keep-Alive: timeout=5, max=100
>>>> Connection: Keep-Alive
>>>> Transfer-Encoding: chunked
>>>> Content-Type: text/plain
>>>>
>>>> I suspect the "Content-Type: text/plain" is a clue.  Straight to Tomcat I see:
>>>>
>>>> HTTP/1.x 200 OK
>>>> Server: Apache-Coyote/1.1
>>>> Set-Cookie: JSESSIONID=53C3EC973BB365AAF92A1EC66F03271A; Path=/Construction
>>>> Transfer-Encoding: chunked
>>>> Date: Sat, 25 Apr 2009 11:37:06 GMT
>>>>
>>>> No "Content-Type" produced at all.
>>>>
>>>> When I access it with Firefox via the Apache reverse proxy via the URL http://myserver/Construction/index.html (which is just mapped in web.xml to the controlling servlet, and my welcome-file is index.html), the webapp displays correctly, and the headers say:
>>>>
>>>> HTTP/1.x 200 OK
>>>> Date: Sat, 25 Apr 2009 11:42:27 GMT
>>>> Server: Apache-Coyote/1.1
>>>> Keep-Alive: timeout=5, max=100
>>>> Connection: Keep-Alive
>>>> Transfer-Encoding: chunked
>>>> Content-Type: text/html
>>>>
>>>> I have 3 different webapps, but I only see the problem with one of them.
>>>>
>>>> My reverse proxy configuration includes:
>>>>
>>>> ProxyPass        /Construction http://localhost:8080/Construction
>>>> ProxyPassReverse /Construction http://localhost:8080/Construction
>>>>
>>>> David
>>>>
>>>> dfobox wrote:
>>>>> I have JSP-based website running on my own server and I want to move it to
>>>>> hosting company. I've copied the files, they said they have enabled Tomcat
>>>>> for me, but browser shows source of the pages, even of those which don't
>>>>> have any script code inside - only properly formatted html. What could be a
>>>>> problem? Thanks!
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>> _________________________________________________________________
>>> Rediscover Hotmail®: Get e-mail storage that grows with you. 
>>> http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

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


Re: Browser shows source of .jsp file. Why?

Posted by Andre-John Mas <aj...@sympatico.ca>.
On 27-Apr-2009, at 18:15, Andre-John Mas wrote:

>
> On 27-Apr-2009, at 09:04, Pid wrote:
>
>> David Rush wrote:
>>> I checked my web.xml, and found no mime-mapping elements at all.   
>>> I tried adding one explicitly mapping the jsp extension to text/ 
>>> html, but it had no effect.  I'm still getting HTML markup in the  
>>> browser window with Firefox.
>>>
>>> David
>>
>> Ignore that, it's a red herring, you don't need to add mime-mappings.
>>
>> You say the problem occurs 'sometimes' with Firefox, can you  
>> elaborate
>> on which times and if there's a commonality between these requests?
>>
>>
>> The fault is usually in the AJP mapping you've configured.  Are you
>> using mod_jk, and if so, what is the config?
>>
>> Also, try splitting your HTTP docroot and Tomcat webapps folders (a
>> correct mapping will mean it still works properly).  If the JSPs  
>> are in
>> another location than the HTTP docs, they can't be served as raw  
>> HTML,
>> by accident.
>
> He indicated in an earlier post that it was his hosting provider who  
> deployed
> his application.
>
> David, have you been able to find out how your hosting company  
> deployed your
> application? Also, what is there "server" header value in the  
> response header?
>
> If your web application is properly deployed then there is no reason  
> your
> web browser should see the raw JSP. This is because if everything  
> works
> correctly Tomcat will have interpreted the JSP and returned you the  
> result
> of that.
>
> If in doubt, try to simulate the set up on your machine. Even if it  
> doesn't
> solve the hosting provider side of things, it should help you gain a  
> better
> understanding of how things work.
>
> André-John

I should have included an example of the headers to help you diagnose  
the
situation. In my case I have Tomcat sitting behind Apache HTTPD. If I  
access
Tomcat via HTTPD I see:

Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.7l DAV/2 PHP/ 
5.2.8 mod_jk/1.2.27

If I access the Tomcat server straight, I see this:

Server: Apache-Coyote/1.1

If you are using Firefox, and you have the Web Developer extension  
installed, then
in the toolbar select Information -> View Response Headers.

Hopefully this should help in your analysis.

André-John




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


Re: Browser shows source of .jsp file. Why?

Posted by Pid <p...@pidster.com>.
David Rush wrote:
> I checked my web.xml, and found no mime-mapping elements at all.  I tried adding one explicitly mapping the jsp extension to text/html, but it had no effect.  I'm still getting HTML markup in the browser window with Firefox.
> 
> David

Ignore that, it's a red herring, you don't need to add mime-mappings.

You say the problem occurs 'sometimes' with Firefox, can you elaborate
on which times and if there's a commonality between these requests?


The fault is usually in the AJP mapping you've configured.  Are you
using mod_jk, and if so, what is the config?

Also, try splitting your HTTP docroot and Tomcat webapps folders (a
correct mapping will mean it still works properly).  If the JSPs are in
another location than the HTTP docs, they can't be served as raw HTML,
by accident.


p





> Martin Gainty wrote:
>> David
>>
>> did you check your mime-mapping in your web.xml 
>> perchance are you mapping jsp to text/plain?
>> is any other extension mapped to text/plain?
>>
>>     <mime-mapping>
>>         <extension>jsp</extension>
>>         <mime-type>text/plain</mime-type>
>>     </mime-mapping>
>>
>> Martin 
>> ______________________________________________ 
>> Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
>> This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
>> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
>>
>>
>>
>>
>>
>>
>>> Date: Sat, 25 Apr 2009 05:46:03 -0600
>>> From: david@rushtone.com
>>> To: users@tomcat.apache.org
>>> Subject: Re: Browser shows source of .jsp file. Why?
>>>
>>> I'm having the same problem, where markup is sometimes appearing in the browser window instead of the rendered HTML.
>>>
>>> I'm using my own server (MS Windows Server 2003), with Tomcat 6.0.18 behind a reverse proxy on Apache 2.2.11.
>>>
>>> When I access one of my webapps via Tomcat's port (http://myserver:8080/Construction/) it works fine.  When I access it via the reverse proxy (http://myserver/Construction) using Firefox 3.0.9 I see the HTML markup displayed in the browser's window.  When I access the webapp via IE either way, it works fine.  Google Chrome produces the same results as Firefox.
>>>
>>> Via Live HTTP Headers, when I access through the reverse proxy I see:
>>>
>>> HTTP/1.x 200 OK
>>> Date: Sat, 25 Apr 2009 11:39:11 GMT
>>> Server: Apache-Coyote/1.1
>>> Keep-Alive: timeout=5, max=100
>>> Connection: Keep-Alive
>>> Transfer-Encoding: chunked
>>> Content-Type: text/plain
>>>
>>> I suspect the "Content-Type: text/plain" is a clue.  Straight to Tomcat I see:
>>>
>>> HTTP/1.x 200 OK
>>> Server: Apache-Coyote/1.1
>>> Set-Cookie: JSESSIONID=53C3EC973BB365AAF92A1EC66F03271A; Path=/Construction
>>> Transfer-Encoding: chunked
>>> Date: Sat, 25 Apr 2009 11:37:06 GMT
>>>
>>> No "Content-Type" produced at all.
>>>
>>> When I access it with Firefox via the Apache reverse proxy via the URL http://myserver/Construction/index.html (which is just mapped in web.xml to the controlling servlet, and my welcome-file is index.html), the webapp displays correctly, and the headers say:
>>>
>>> HTTP/1.x 200 OK
>>> Date: Sat, 25 Apr 2009 11:42:27 GMT
>>> Server: Apache-Coyote/1.1
>>> Keep-Alive: timeout=5, max=100
>>> Connection: Keep-Alive
>>> Transfer-Encoding: chunked
>>> Content-Type: text/html
>>>
>>> I have 3 different webapps, but I only see the problem with one of them.
>>>
>>> My reverse proxy configuration includes:
>>>
>>> ProxyPass        /Construction http://localhost:8080/Construction
>>> ProxyPassReverse /Construction http://localhost:8080/Construction
>>>
>>> David
>>>
>>> dfobox wrote:
>>>> I have JSP-based website running on my own server and I want to move it to
>>>> hosting company. I've copied the files, they said they have enabled Tomcat
>>>> for me, but browser shows source of the pages, even of those which don't
>>>> have any script code inside - only properly formatted html. What could be a
>>>> problem? Thanks!
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>> _________________________________________________________________
>> Rediscover Hotmail®: Get e-mail storage that grows with you. 
>> http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


Re: Browser shows source of .jsp file. Why?

Posted by David Rush <da...@rushtone.com>.
I checked my web.xml, and found no mime-mapping elements at all.  I tried adding one explicitly mapping the jsp extension to text/html, but it had no effect.  I'm still getting HTML markup in the browser window with Firefox.

David

Martin Gainty wrote:
> David
> 
> did you check your mime-mapping in your web.xml 
> perchance are you mapping jsp to text/plain?
> is any other extension mapped to text/plain?
> 
>     <mime-mapping>
>         <extension>jsp</extension>
>         <mime-type>text/plain</mime-type>
>     </mime-mapping>
> 
> Martin 
> ______________________________________________ 
> Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
> This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> 
> 
> 
> 
> 
> 
>> Date: Sat, 25 Apr 2009 05:46:03 -0600
>> From: david@rushtone.com
>> To: users@tomcat.apache.org
>> Subject: Re: Browser shows source of .jsp file. Why?
>>
>> I'm having the same problem, where markup is sometimes appearing in the browser window instead of the rendered HTML.
>>
>> I'm using my own server (MS Windows Server 2003), with Tomcat 6.0.18 behind a reverse proxy on Apache 2.2.11.
>>
>> When I access one of my webapps via Tomcat's port (http://myserver:8080/Construction/) it works fine.  When I access it via the reverse proxy (http://myserver/Construction) using Firefox 3.0.9 I see the HTML markup displayed in the browser's window.  When I access the webapp via IE either way, it works fine.  Google Chrome produces the same results as Firefox.
>>
>> Via Live HTTP Headers, when I access through the reverse proxy I see:
>>
>> HTTP/1.x 200 OK
>> Date: Sat, 25 Apr 2009 11:39:11 GMT
>> Server: Apache-Coyote/1.1
>> Keep-Alive: timeout=5, max=100
>> Connection: Keep-Alive
>> Transfer-Encoding: chunked
>> Content-Type: text/plain
>>
>> I suspect the "Content-Type: text/plain" is a clue.  Straight to Tomcat I see:
>>
>> HTTP/1.x 200 OK
>> Server: Apache-Coyote/1.1
>> Set-Cookie: JSESSIONID=53C3EC973BB365AAF92A1EC66F03271A; Path=/Construction
>> Transfer-Encoding: chunked
>> Date: Sat, 25 Apr 2009 11:37:06 GMT
>>
>> No "Content-Type" produced at all.
>>
>> When I access it with Firefox via the Apache reverse proxy via the URL http://myserver/Construction/index.html (which is just mapped in web.xml to the controlling servlet, and my welcome-file is index.html), the webapp displays correctly, and the headers say:
>>
>> HTTP/1.x 200 OK
>> Date: Sat, 25 Apr 2009 11:42:27 GMT
>> Server: Apache-Coyote/1.1
>> Keep-Alive: timeout=5, max=100
>> Connection: Keep-Alive
>> Transfer-Encoding: chunked
>> Content-Type: text/html
>>
>> I have 3 different webapps, but I only see the problem with one of them.
>>
>> My reverse proxy configuration includes:
>>
>> ProxyPass        /Construction http://localhost:8080/Construction
>> ProxyPassReverse /Construction http://localhost:8080/Construction
>>
>> David
>>
>> dfobox wrote:
>>> I have JSP-based website running on my own server and I want to move it to
>>> hosting company. I've copied the files, they said they have enabled Tomcat
>>> for me, but browser shows source of the pages, even of those which don't
>>> have any script code inside - only properly formatted html. What could be a
>>> problem? Thanks!
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> 
> _________________________________________________________________
> Rediscover Hotmail®: Get e-mail storage that grows with you. 
> http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009

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


RE: Browser shows source of .jsp file. Why?

Posted by Martin Gainty <mg...@hotmail.com>.
David

did you check your mime-mapping in your web.xml 
perchance are you mapping jsp to text/plain?
is any other extension mapped to text/plain?

    <mime-mapping>
        <extension>jsp</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>

Martin 
______________________________________________ 
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.






> Date: Sat, 25 Apr 2009 05:46:03 -0600
> From: david@rushtone.com
> To: users@tomcat.apache.org
> Subject: Re: Browser shows source of .jsp file. Why?
> 
> I'm having the same problem, where markup is sometimes appearing in the browser window instead of the rendered HTML.
> 
> I'm using my own server (MS Windows Server 2003), with Tomcat 6.0.18 behind a reverse proxy on Apache 2.2.11.
> 
> When I access one of my webapps via Tomcat's port (http://myserver:8080/Construction/) it works fine.  When I access it via the reverse proxy (http://myserver/Construction) using Firefox 3.0.9 I see the HTML markup displayed in the browser's window.  When I access the webapp via IE either way, it works fine.  Google Chrome produces the same results as Firefox.
> 
> Via Live HTTP Headers, when I access through the reverse proxy I see:
> 
> HTTP/1.x 200 OK
> Date: Sat, 25 Apr 2009 11:39:11 GMT
> Server: Apache-Coyote/1.1
> Keep-Alive: timeout=5, max=100
> Connection: Keep-Alive
> Transfer-Encoding: chunked
> Content-Type: text/plain
> 
> I suspect the "Content-Type: text/plain" is a clue.  Straight to Tomcat I see:
> 
> HTTP/1.x 200 OK
> Server: Apache-Coyote/1.1
> Set-Cookie: JSESSIONID=53C3EC973BB365AAF92A1EC66F03271A; Path=/Construction
> Transfer-Encoding: chunked
> Date: Sat, 25 Apr 2009 11:37:06 GMT
> 
> No "Content-Type" produced at all.
> 
> When I access it with Firefox via the Apache reverse proxy via the URL http://myserver/Construction/index.html (which is just mapped in web.xml to the controlling servlet, and my welcome-file is index.html), the webapp displays correctly, and the headers say:
> 
> HTTP/1.x 200 OK
> Date: Sat, 25 Apr 2009 11:42:27 GMT
> Server: Apache-Coyote/1.1
> Keep-Alive: timeout=5, max=100
> Connection: Keep-Alive
> Transfer-Encoding: chunked
> Content-Type: text/html
> 
> I have 3 different webapps, but I only see the problem with one of them.
> 
> My reverse proxy configuration includes:
> 
> ProxyPass        /Construction http://localhost:8080/Construction
> ProxyPassReverse /Construction http://localhost:8080/Construction
> 
> David
> 
> dfobox wrote:
> > I have JSP-based website running on my own server and I want to move it to
> > hosting company. I've copied the files, they said they have enabled Tomcat
> > for me, but browser shows source of the pages, even of those which don't
> > have any script code inside - only properly formatted html. What could be a
> > problem? Thanks!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

_________________________________________________________________
Rediscover Hotmail®: Get e-mail storage that grows with you. 
http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009

Re: Browser shows source of .jsp file. Why?

Posted by Ken Bowen <kb...@als.com>.
The variation between Content-Type: text/plain and Content-Type: text/ 
html is definitely your clue.
The fact that it displays correctly when there is no Content-Type:   
header is simply evidence that browser make (reasonable) guesses.
You need to determine where this variation is coming from.
If your code is directly writing the servlet responses anywhere, you  
need to make sure that a setContentType("text/html") is executed.

On Apr 25, 2009, at 7:46 AM, David Rush wrote:

> I'm having the same problem, where markup is sometimes appearing in  
> the browser window instead of the rendered HTML.
>
> I'm using my own server (MS Windows Server 2003), with Tomcat 6.0.18  
> behind a reverse proxy on Apache 2.2.11.
>
> When I access one of my webapps via Tomcat's port (http://myserver:8080/Construction/ 
> ) it works fine.  When I access it via the reverse proxy (http://myserver/Construction 
> ) using Firefox 3.0.9 I see the HTML markup displayed in the  
> browser's window.  When I access the webapp via IE either way, it  
> works fine.  Google Chrome produces the same results as Firefox.
>
> Via Live HTTP Headers, when I access through the reverse proxy I see:
>
> HTTP/1.x 200 OK
> Date: Sat, 25 Apr 2009 11:39:11 GMT
> Server: Apache-Coyote/1.1
> Keep-Alive: timeout=5, max=100
> Connection: Keep-Alive
> Transfer-Encoding: chunked
> Content-Type: text/plain
>
> I suspect the "Content-Type: text/plain" is a clue.  Straight to  
> Tomcat I see:
>
> HTTP/1.x 200 OK
> Server: Apache-Coyote/1.1
> Set-Cookie: JSESSIONID=53C3EC973BB365AAF92A1EC66F03271A; Path=/ 
> Construction
> Transfer-Encoding: chunked
> Date: Sat, 25 Apr 2009 11:37:06 GMT
>
> No "Content-Type" produced at all.
>
> When I access it with Firefox via the Apache reverse proxy via the  
> URL http://myserver/Construction/index.html (which is just mapped in  
> web.xml to the controlling servlet, and my welcome-file is  
> index.html), the webapp displays correctly, and the headers say:
>
> HTTP/1.x 200 OK
> Date: Sat, 25 Apr 2009 11:42:27 GMT
> Server: Apache-Coyote/1.1
> Keep-Alive: timeout=5, max=100
> Connection: Keep-Alive
> Transfer-Encoding: chunked
> Content-Type: text/html
>
> I have 3 different webapps, but I only see the problem with one of  
> them.
>
> My reverse proxy configuration includes:
>
> ProxyPass        /Construction http://localhost:8080/Construction
> ProxyPassReverse /Construction http://localhost:8080/Construction
>
> David
>
> dfobox wrote:
>> I have JSP-based website running on my own server and I want to  
>> move it to
>> hosting company. I've copied the files, they said they have enabled  
>> Tomcat
>> for me, but browser shows source of the pages, even of those which  
>> don't
>> have any script code inside - only properly formatted html. What  
>> could be a
>> problem? Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


Re: Browser shows source of .jsp file. Why?

Posted by David Rush <da...@rushtone.com>.
I'm having the same problem, where markup is sometimes appearing in the browser window instead of the rendered HTML.

I'm using my own server (MS Windows Server 2003), with Tomcat 6.0.18 behind a reverse proxy on Apache 2.2.11.

When I access one of my webapps via Tomcat's port (http://myserver:8080/Construction/) it works fine.  When I access it via the reverse proxy (http://myserver/Construction) using Firefox 3.0.9 I see the HTML markup displayed in the browser's window.  When I access the webapp via IE either way, it works fine.  Google Chrome produces the same results as Firefox.

Via Live HTTP Headers, when I access through the reverse proxy I see:

HTTP/1.x 200 OK
Date: Sat, 25 Apr 2009 11:39:11 GMT
Server: Apache-Coyote/1.1
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/plain

I suspect the "Content-Type: text/plain" is a clue.  Straight to Tomcat I see:

HTTP/1.x 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=53C3EC973BB365AAF92A1EC66F03271A; Path=/Construction
Transfer-Encoding: chunked
Date: Sat, 25 Apr 2009 11:37:06 GMT

No "Content-Type" produced at all.

When I access it with Firefox via the Apache reverse proxy via the URL http://myserver/Construction/index.html (which is just mapped in web.xml to the controlling servlet, and my welcome-file is index.html), the webapp displays correctly, and the headers say:

HTTP/1.x 200 OK
Date: Sat, 25 Apr 2009 11:42:27 GMT
Server: Apache-Coyote/1.1
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

I have 3 different webapps, but I only see the problem with one of them.

My reverse proxy configuration includes:

ProxyPass        /Construction http://localhost:8080/Construction
ProxyPassReverse /Construction http://localhost:8080/Construction

David

dfobox wrote:
> I have JSP-based website running on my own server and I want to move it to
> hosting company. I've copied the files, they said they have enabled Tomcat
> for me, but browser shows source of the pages, even of those which don't
> have any script code inside - only properly formatted html. What could be a
> problem? Thanks!

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


Re: Browser shows source of .jsp file. Why?

Posted by Pid <p...@pidster.com>.
dfobox wrote:
> answer is pretty simple

It sounds like their setup is publishing the JSP files under the HTTP
document root as well as under the Tomcat webapps directory.  This often
causes the issue you experienced, and presents a security risk.

If you can, I'd recommend separating out the two directories and placing
them in an appropriate location.  Whichever of mod_jk or mod_proxy is in
use can be configured to direct the requests to the apppropriate
location.  E.g.

 /sites/your.domain.org/httpdocs
 /sites/your.domain.org/webapps

With this setup, I would typically map all requests to Tomcat, except
for /scripts, /styles, /images and this would usually ensure that there
aren't any URL mapping accidents like the one you describe.


p




> "NOTE: If your domain name is NOT pointing to our service yet you will need
> to add your domain name and your server IP in your local hosts file in order
> for you to be able to access your JSP pages since otherwise the Tomcat will
> not render the context for your domain. For more info on how to include your
> domain/IP in your local computer's hosts file please check:
> 
> http://en.wikipedia.org/wiki/Hosts_file"
> 
> I've just added a line to hosts file to substitute my domain name by ip
> address


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


Re: Browser shows source of .jsp file. Why?

Posted by dfobox <df...@gmail.com>.
answer is pretty simple

"NOTE: If your domain name is NOT pointing to our service yet you will need
to add your domain name and your server IP in your local hosts file in order
for you to be able to access your JSP pages since otherwise the Tomcat will
not render the context for your domain. For more info on how to include your
domain/IP in your local computer's hosts file please check:

http://en.wikipedia.org/wiki/Hosts_file"

I've just added a line to hosts file to substitute my domain name by ip
address
-- 
View this message in context: http://www.nabble.com/Browser-shows-source-of-.jsp-file.-Why--tp23226583p23228707.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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