Oh, this is just a nightmare.
Using JavaServer Faces, here are the options:
1. Just add a JSP directive:
<jsp:directive.page contentType="text/html"/>
Of course, that turns *all* pages into text/html, which we don't want to do for non-broken browsers such as Firefox and Mozilla.
2. Add a script to check for what the browser accepts:
<jsp:directive.page import="java.util.Enumeration"/>
<jsp:scriptlet>
String contentType="text/html";
final Enumeration httpAcceptEnumeration=request.getHeaders("accept");
while(httpAcceptEnumeration.hasMoreElements())
{if(((String)httpAcceptEnumeration.nextElement()).indexOf("application/xhtml+xml")>=0)
{
contentType="application/xhtml+xml";
break;}
}
response.setContentType(contentType); //set the content type to whatever we decided upon
</jsp:scriptlet>
That works really well; on Firefox it returns application/xhtml+xml, and for buggy browsers (and browsers that don't support XML at all, IE being the former) it returns text/html.
But do I want to put all of that junk in all of my JavaServer Faces files? I don't think so. Inclusion sounds perfect, but here's the problem: if I include the code statically, it doesn't get executed. If I include it dynamically, it doesn't correctly set the content-type header because its output is fed into the main page, which is working with the real HTTP request/response.
Anyone have an idea on this really nasty situation? Or should I just go back to sending out HTML 3.x?
Garret
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
