Content Negotiation with JSP

L

Lachlan Hunt

Hi,
Is it possible to set up content negotiation to dynamically set the
content type of a JSP page? At the moment, the pages are hard coded
using the @page directive like this:
<%@ page contentType="text/html; charset=UTF-8" %>

and during development, I manually change it to application/xhtml+xml so
I can more quickly find validation errors, however I would like to be
able to determine what mime types are accepted by the client, and if
application/xhtml+xml is supported, deliver it, or text/html otherwise.
That would make development easier, and would mean that there is
actually a valid reason for using XHTML1, rather than HTML4, after
development is complete.

--
Lachlan Hunt
http://www.lachy.id.au/
lachlan . hunt at lachy . id . au

Please direct all spam to abuse@localhost
Thank you.
 
A

Andrew Thompson

Is it possible to set up content negotiation to dynamically set the
content type of a JSP page? At the moment, the pages are hard coded
using the @page directive like this:
<%@ page contentType="text/html; charset=UTF-8" %>

Yes. It is best done by the server itself,
which either means negotiating with your host,
or if you are lucky enough to be running Apache,
uploading an .htaccess file with appropriate
scribings..

E.G.
AddType text/jsp jsp
AddCharset utf-8 .jsp

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top