Вопрос

My client is running a Java-based server with no PHP enabled and no access to the .htaccess file. I want to be able to serve CSS3PIE up to the server, and have it simply work. I would absolutely prefer not to use the JS version. How can I let Java serve up the file with the correct content type in much the way that PHP does?

<?php
header( 'Content-type: text/x-component' );
include( 'PIE.htc' );
?>

This PHP file sets the header of the page to allow for text/x-component which in turn allows for HTC files in IE.

In short, are there any workarounds for using PIE.htc without .htaccess, PHP, or the JS files?

Это было полезно?

Решение

JavaServer Pages (JSP) has page directives that are very similar to PHP. The following is equivalent to your PHP example:

<%@ page contentType="text/x-component" %><%@ include file="PIE.htc" %>

You can put that in any JSP file you like, for example a file named pie.jsp. That means you will need to point to the .jsp file in your CSS instead of the .htc file:

behavior: url(pie.jsp);

That should be all you need to do. However if you want to have the .htc file extension in your URLs instead of .jsp, then you could configure the Java application server to render .htc files as JSPs, and then put the above directives into a .htc file instead. See Can you render a file without a .jsp extension as a JSP? for details.


Documentation

JSP page directive: http://docs.oracle.com/javaee/5/tutorial/doc/bnahj.html

JSP include directive: http://docs.oracle.com/javaee/5/tutorial/doc/bnajb.html

Другие советы

Add this line to your apache configuration:

AddType text/x-component .htc

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top