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: da...@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-unsubscr...@tomcat.apache.org
>>>>>> For additional commands, e-mail: users-h...@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-unsubscr...@tomcat.apache.org
>>>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 
> 
> 

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

Reply via email to