Configuration of SSI in Tomcat report--tomcat

Source: Internet
Author: User
Tags local time compressed file types tomcat server

1. Introduction:

The SSI full name (Server Side Includes) is an instruction used in an HTML static page that can be parsed by the server when it is executed on the server side. This approach allows us to block dynamically generated content in existing HTML pages without dynamic page service based on the entire server-side technology that executes CGI. Before returning the requested page (which contains SSI directives), the server processes the instructions, replaces the instructions with the results of the processing, and returns the page. When we use Tomcat as an HTTP server, we need to use SSI to add support for SSI to Tomcat.

The SSI support for the Tomcat server is implemented in the same way as the SSI instructions in Apache, where SSI support is implemented using a servlet and one filter (the basic information Reference JSP tutorial for servlet and filter). We can use one of these methods for SSI-supported configurations, but not two simultaneous configurations, and whether or not there is a conflict I'm not quite sure, so configure one on a regular basis.

The servlet implementation that implements SSI support uses Org.apache.catalina.ssi.SSIServlet, and additional mapping rules "*.shtml" are added to the servlet's path resolution.

The filter that implements SSI support uses Org.apache.calalina.ssi.SSIFilter. In addition, the mapping rule "*.shtml" needs to be added in the filter path resolution, and the initialization parameters of the MIME type,contenttype that can be executed in the mapping rule are added to the filter configuration to allow you to execute resources below the server. In Tomcat, SSI is disabled by default.

Note: The SSI command executes the JVM outside of Tomcat, if we need to configure it in the Calalina.policy file using the Java Security Manager. To use the SSI servlet and SSI Filter, remove the SSI annotations directly from the server's path $catalina_base/conf/web.xml file. It should be noted that only the context where the privileged is marked in the Tomcat server can use SSI functionality. (*: When privileged is set to true, the Tomcat Web application is allowed to use the domain of Lib that is used in the container's Servlet,tomcat document, and each application cannot access the servlet within the container without setting this property. This should refer to the global servlet.

Otherwise, you will encounter an exception:

Java.lang.SecurityException:Filter of Class Org.apache.catalina.ssi.SSIFilter (Ssiservlet) is privileged and cannot are Loaded by this web application

2. Server Configuration Properties:

The parameters to be used when configuring the SSI servlet (init parameters) are as follows:

Buffered: is required to save input to buffer (0=false,1=true) default is 0 (false)

Debue: Configure logging level for debug logs, default 0;

Expires:ssi contains the timeout configuration for a page, and the default behavior is that all SSI directives are executed on each request

Isvirtualwebapprelative: is the relative path resolution for the root (virtual directory) of the Tomcat context or the server directory for Tomcat (0=false,1=true) by default 0, not using virtual directories.

Inputencoding: If the resource is not its own, resources from outside the container, you can set the encoding for external resources, what kind of political reform to enter resources, by default, using the resources on the platform used by the encoding.

Outputencoding:ssi the encoding that executes the output of the result, which is UTF-8 by default.

The following parameters (init paramters) are required when configuring SSI filter:

ContextType: Configure a regular expression rule that can be matched for SSI execution, and if you customize your own matching rules, you need to configure the following options within the MIME type: In the form, set the "Mime/type;charset=set" by default " Text/x-server-parsed-html (;. *)?”

Debug: Ditto

Expires: Ditto

Isvirtualwebapprelative: Ditto

3. Instruction Description:

SSI is called by an SSI servlet that contains portions of the HTML document that need to be processed. These directives are annotated forms of HTML documents that are replaced with content before they are sent to the client. The standard format is as follows:

<!--#directive [Parm=value]-->

These directives include:

Config: Set date format other data that is processed by SSI (<!--#config timefmt= "%B%Y"-->)

Echo: will be replaced by the value of the variable (<!--#echo var= "Variable_naem"-->)

EXEC: Used to execute server-side commands

Include: contains some content (<!--#include virtual= "File-name"-->)

Flastmod: Returns the time when a file was last modified (<!--#flastmod file= "filename.shtml"-->)

Fsize: Returns the size of a file (<!--#fzie file= "filename.shtml"-->)

PRINTENV: Returns all defined variables (<!--#printenv-->)

Set: Used to assign values to defined variables (<!--#set var= "foo" value= "Bar"-->)

If Elif endif else: Create conditional Branch Statement

Apache SSI Official documentation

The variables in the 4.SSI servlet are as follows:

auth_type--for the user's authentication authorization mode: BASIC,FORM,ETC. and tomcat Authentication Mode synchronization

content_length--The data length, number of characters, or number of bytes of data conveys from the server table.

content_type--server access the MIME type of the data, such as "text/html"

date_gmt--current time format method using GMT

date_local--the current time format as a local time format

document_name--the file address of the current context environment

document_uri--the file address defined by the virtual path

gateway_interface--cgi version definition: "cgi/1.1"

http_accept--a list of MIME types that a client can accept

http_accept_encoding--a list of compressed file types that clients can accept

List of Languages http_accept_language--clients can support

http_connection--Manage client connections: "Close" or "keep-alive"

http_host--the site address requested by the client

http_referer--the URL address before the client request

http_user_agent--client's browser-side request results

last_modified--when the current page was last accessed and modified

path_info--access to this servlet's path information

Translated version provided by Path_translated--path_info

Query_string

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.