Is there anything wrong with creating a ".jsp" page that is pure html with no scripts? I have a page like this in a site I built that lies in a chain of other jsp pages that do have scripts. I made the page a jsp page because I wasn't initially sure if I would use dynamic elements on that page or not. And I didn't think this mattered.
All the jsp pages display fine on firefox/netscape/ie when viewed on a windows machine (I wouldn't expect the browser to matter since the html is generated server-side). However, when I view the site using a safari browser on a mac machine a problem occurs: the first time I hit the html-only jsp page, it displays fine. However, every time I hit this page subsequently, safari displays the page's source code. Then if I hit the "refresh" button, it displays the page properly. But if I move to another page and then go back to the problem page, safari displays code again unless I refresh. All of the other jsp pages (that actually contain jsp scripts) are fine.
I'm not sure why this would happen since the server is sending complete and valid html code to the browser. I even copied the code that safari was receiving and ran it through a markup validator. No errors.
Is there anything wrong with having a ".jsp" page with no jsp tags? Is there a certain "<%@ page ...%> declaration required? Incidentally, I tested for this problem both with and without this...
Then pick a shade you like and click "add to cart". Then hit the "checkout" button. This (chooseDelivery.jsp) is the problem page (but it should display correctly the first time). Click "Ship it over land". This should call up chooseDestination.jsp. Next, hit the "back" button. You should now see html code instead of the correctly rendered page. Hit "refresh" and the page appears correctly. Now hit "back" and then "checkout" again. Displays code again.
Why? Am I missing something very simple here?
I very much appreciate any insight you may have into this problem.
That's exactly my setup. So I ain't got much more...
Has this problem been observed on mutiple Macs, or just the one? Try as I might, I cannot reproduce the behavior you report on any of my three Macs.
Joined: Oct 27, 2005
Thanks very much Bear for checking again.
Actually, I just saw the problem again earlier tonight on a completely different mac in a different home, this one running OS 10.4.3 and safari version 2.0.2.
Maybe I wasn't clear describing how to obtain the problem. The first time you hit the chooseDelivery.jsp page, it should display correctly. Then, when you hit the "back" button from the page named chooseDestination.jsp, be sure to hit the "back" button link on the page, instead of the "back" button on the browser. Otherwise, the broser will just show the cached page.
I just did this using the liveHttpHeaders plugin on FireFox and the content type was "text/plain".
The problem only seems to be happening when I request the page in such a way as to get a 304 response code (such as using the back or refresh buttons). If I type the url in directly (and make sure it's unique), the content type comes back as 'text/html'.
So the problem really has nothing to do with the Mac client. It's actually doing exactly what it's supposed to do. MSIE and FF are masking the problem by ignoring the headers and displaying the JSP as HTML (sad to see FF doing this).
It looks like you're using Resin as your JSP/Servlet container with Apache HTTPD (which I'll refer to as just "Apache") as the web server.
Here's my first stab in the dark: Apache is configured to pass all JSP requests to Resin. If Resin returns a 304 (not modified) header, Apache doesn't bother to read the rest of the headers. It just sends back it's own response with it's configured mime typing. I'm also guessing that there is no mime type set up for ".jsp" so it is sending back the default which is "text/plain". If I'm right, the fix is to add the mime type for 'jsp' in httpd.conf.
One test you might want to try is to hit Resin directly (if you can). If it works correctly when hitting Resin as a standalone, then you know that the culprit is either the connector or Apache httpd itself. [ February 07, 2006: Message edited by: Ben Souther ]
Thanks for your suggestions, Ben. Yes, the site uses Resin. Unfortunately, the site is hosted with a shared jvm. I don't have much control. And as far as I can tell, I don't have the ability to modify a httpd.conf file. Where is the file usually located?
And I'm not sure what you mean by "hitting resin directly". How does one do this? You mean without a browser?
I'm not especially familiar with mime typing and don't fully understand your explanation.
I appreciate your suggestions, though. Let me know if there is something else you think I should test and/or how to implement the test (as my knowledge oif mime typing and such is minimal).
I'd really like to know how to fix this problem (other than changing the page to html).
subject: html-only jsp page displaying source in safari browser on a mac