Garret Wilson wrote:

Oh, this is just a nightmare.

Using JavaServer Faces, here are the options:

1. Just add a JSP directive:
2. Add a script to check for what the browser accepts:

3. Use a Filter -- here's a quick example, you may need to tweak it for your particular situation --

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;

public class Accept implements Filter {

  private FilterConfig config = null;
  private String  htmlContentType = "text/html";
  private String xhtmlContentType = "application/xhtml+xml";

  public void init(FilterConfig config) throws ServletException
  {
    this.config = config;
  }

  public void destroy()
  {
    config = null;
  }

public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException
{
String thisContentType = "";
if (request instanceof HttpServletRequest)
{
String AcceptHeader = ((HttpServletRequest)request).getHeader("Accept").toString();


      if ( AcceptHeader.matches(".*application/xhtml\\+xml.*") )
      {
        thisContentType = xhtmlContentType;
      }
      else
      {
        thisContentType = htmlContentType;
      }
    }
    response.setContentType(thisContentType);
    chain.doFilter(request, response);
  }
}

HTH!
--
Hassan Schroeder ----------------------------- [EMAIL PROTECTED]
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                          dream.  code.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to