Enable SSI on Tomcat Apache.
Disclaimer : This blog and all of its content is for beginners, so geeks and gods please don't feel offended by my posts.
In one of my projects it was required to enable SSI on Tomact Apache running as Window service. It took me a quite a time to figure it out, I seriously don't know if I was dumb that took me so long to get this done but anyways I felt sharing this with you.
Lets get started. Please follow step by step.
You need to modify two files inside the conf folder. First one is web.xml and other is context.xml.
1. Modifications in web.xml.
- Uncomment servlet with servlet name as 'ssi'.
- Uncomment servlet-mapping for this servlet i.e 'ssi'
- If you want to support SSI for .html file extension also then add one more servlet mapping . Finally your mapping should look like this
<servlet-mapping>
<servlet-name>ssi</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ssi</servlet-name>
<url-pattern>*.shtml</url-pattern>
</servlet-mapping>
- Uncomment mime-mapping with extension "shtml"
2. Modifications in context.xml
- Add attribute privileged="true" to Context tag. Your context tag should like following
Adding privileged="true" enables this context to use container
servlets, in our case this is ssi servlet.
Open any text editor and write the following SSI directive in it.
<!--#config timefmt="%A" --> <!--#echo var="DATE_LOCAL" -->
Save this as test.shtml and test.html.
Host this on your Tomcat.
Hit this from browser and it should display current day.
Time for a Test.
Open any text editor and write the following SSI directive in it.
<!--#config timefmt="%A" --> <!--#echo var="DATE_LOCAL" -->
Save this as test.shtml and test.html.
Host this on your Tomcat.
Hit this from browser and it should display current day.
Output of test.html |
P.S. Please leave comments or share your thoughts. Suggestions are welcome.
No comments:
Post a Comment