Configure tomcat6.41 to support SSI

Source: Internet
Author: User

Official Tomcat Documentation

Caution-Ssi directives can be used to execute programs external to the Tomcat JVM. If you are using the Java securitymanager this will bypass your security policy configuration incatalina.policy.

To use the SSI servlet, remove the XML comments from around the SSI Servlet and servlet-mapping configuration in$CATALINA_BASE/conf/web.xml.

To use the SSI filter, remove the XML comments from around the SSI filter and filter-mapping configuration in$CATALINA_BASE/conf/web.xml.

Only contexts which are marked as privileged may use SSI features (see the privileged property of the context element ).

 

Tomcat supports SSI in two ways: Servlet and filter.

Servlet-based method:

In web. XML, find

 

<!--    <servlet>        <servlet-name>ssi</servlet-name>        <servlet-class>          org.apache.catalina.ssi.SSIServlet        </servlet-class>        <init-param>          <param-name>buffered</param-name>          <param-value>1</param-value>        </init-param>        <init-param>          <param-name>debug</param-name>          <param-value>0</param-value>        </init-param>        <init-param>          <param-name>expires</param-name>          <param-value>666</param-value>        </init-param>        <init-param>          <param-name>isVirtualWebappRelative</param-name>          <param-value>false</param-value>        </init-param>        <load-on-startup>4</load-on-startup>    </servlet>-->

 

And

<!--<servlet-mapping><servlet-name>ssi</servlet-name><url-pattern>*.shtml</url-pattern></servlet-mapping>-->

Remove comments.

Then set in context. xml

<Context privileged="true">

 

Filter Method:

Find in Web. xml

<!--    <filter>        <filter-name>ssi</filter-name>        <filter-class>          org.apache.catalina.ssi.SSIFilter        </filter-class>        <init-param>          <param-name>contentType</param-name>          <param-value>text/x-server-parsed-html(;.*)?</param-value>        </init-param>        <init-param>          <param-name>debug</param-name>          <param-value>0</param-value>        </init-param>        <init-param>          <param-name>expires</param-name>          <param-value>666</param-value>        </init-param>        <init-param>          <param-name>isVirtualWebappRelative</param-name>          <param-value>false</param-value>        </init-param>    </filter>-->

And

<!-- <filter-mapping>        <filter-name>ssi</filter-name>        <url-pattern>*.shtml</url-pattern> </filter-mapping>-->

And

<!--    <mime-mapping>        <extension>shtml</extension>        <mime-type>text/x-server-parsed-html</mime-type>    </mime-mapping>-->

You also need to set the comment in the context. xml file.

<Context privileged="true">

Restart tomcat.

 

Test

Index.shtml

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> SSI example </title>
</Head>

<Body>
SSI area <! -- # Include virtual = "ssi.html" -->
<P>

Footer <! -- # Include virtual = "footer.html" --> <p>

<P>

<! -- # Config timefmt = "% d" -->
Me Last modified <! -- # Echo Var = "last_modified" -->

</Body>
</Html>


Footer.html

<Ul>
<Li> index </LI>
<Li> about </LI>
</Ul>


Ssi.html

<P> This is ssi.html file </P> <p>
<P> Chinese </P>
Ssi.html file end
<P/>

Now, http: // localhost: 8080/test/index.shtml has the result.

If Chinese characters are garbled, you can add initialization parameters to servlet SSI or filter ssi.

<init-param>    <param-name>inputEncoding</param-name>    <param-value>utf-8</param-value></init-param><init-param>    <param-name>outputEncoding</param-name>    <param-value>utf-8</param-value></init-param>

Reference: http://chenlb.iteye.com/blog/227184

Configure tomcat6.41 to support SSI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.