Good evening,

on my CentOS 7 server I run Jetty by:

# /usr/bin/java -Djdbc.drivers=org.postgresql.Driver -jar
/usr/share/java/jetty-distribution-9.4.27.v20200227/start.jar
jetty.home=/usr/share/java/jetty-distribution-9.4.27.v20200227
jetty.base=/var/www/jetty-base-ru jetty.http.host=127.0.0.1
jetty.http.port=8080

Also I serve PHP files through FastCGI as suggested at
https://www.eclipse.org/jetty/documentation/9.4.28.v20200408/configuring-fastcgi.html

My XML config file is listed at the very bottom of this mail.

However I have a problem: when I create a static HTML file in UTF-8
encoding, with no BOM, Russian language - it is misinterpreted by browsers
and they do not display Russian letters. When I rename the file. from .html
to .php then it works - because the following HTTP header is suddenly added:

    Content-Type: text/html;charset=utf-8

Is there please a way to configure Jetty through the XML file below to send
the header for all HTML files?

I have searched Stackoverflow and the question seems to be complicated
because of the servlet spec.

I would prefer finding an XML option, because it would suit my deployment
and Jetty-upgrades procedure best (i.e. no editing the files distributed
with new Jetty versions, but better just configuring it once in
$JETTY_BASE/webapps)

Thank you and happy Easter :-)
Alex

PS: below is my  /var/www/jetty-base-ru/webapps/slova.de.xml, how to add
the header there?

?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
    "http://www.eclipse.org/jetty/configure_9_3.dtd";>
<Configure class="org.eclipse.jetty.servlet.ServletContextHandler">

    <New id="root" class="java.lang.String">
        <Arg>/var/www/html/slova.de</Arg>
    </New>

    <Set name="contextPath">/</Set>
    <Set name="resourceBase"><Ref refid="root" /></Set>

    <Set name="virtualHosts">
            <Array type="java.lang.String">
                    <Item>slova.de</Item>
                    <Item>www.slova.de</Item>
            </Array>
    </Set>

    <Set name="welcomeFiles">
        <Array type="string">
                <Item>index.php</Item>
                <Item>index.html</Item>
        </Array>
    </Set>

    <Call name="addFilter">
        <Arg>org.eclipse.jetty.fcgi.server.proxy.TryFilesFilter</Arg>
        <Arg>/*</Arg>
        <Arg>
            <Call name="of" class="java.util.EnumSet">
                <Arg><Get name="REQUEST"
class="javax.servlet.DispatcherType" /></Arg>
            </Call>
        </Arg>
        <Call name="setInitParameter">
            <Arg>files</Arg>
            <Arg>$path /index.php?p=$path</Arg>
        </Call>
    </Call>

    <Call name="addServlet">
        <Arg>
            <New class="org.eclipse.jetty.servlet.ServletHolder">
                <Arg>default</Arg>
                <Arg>
                    <Call name="forName" class="java.lang.Class">
                        <Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg>
                    </Call>
                </Arg>
                <Call name="setInitParameter">
                    <Arg>dirAllowed</Arg>
                    <Arg>false</Arg>
                </Call>
                <Call name="setInitParameter">
                    <Arg>gzip</Arg>
                    <Arg>true</Arg>
                </Call>
            </New>
        </Arg>
        <Arg>/</Arg>
    </Call>

    <Call name="addServlet">
        <Arg>org.eclipse.jetty.fcgi.server.proxy.FastCGIProxyServlet</Arg>
        <Arg>*.php</Arg>
        <Call name="setInitParameter">
            <Arg>proxyTo</Arg>
            <Arg>http://localhost:9000</Arg>
        </Call>
        <Call name="setInitParameter">
            <Arg>prefix</Arg>
            <Arg>/</Arg>
        </Call>
        <Call name="setInitParameter">
            <Arg>scriptRoot</Arg>
            <Arg><Ref refid="root" /></Arg>
        </Call>
        <Call name="setInitParameter">
            <Arg>scriptPattern</Arg>
            <Arg>(.+?\\.php)</Arg>
        </Call>
    </Call>

</Configure>
_______________________________________________
jetty-users mailing list
jetty-users@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to