Question

I have a basic web application packaged as an EAR deployed on GlassFish. The web module has some html files. The html files have a common footer, an html file, that I would like to extract out and make an include. When I do, and put:

<!--#include virtual="insertthisfile.html" -->

in an html file, it does not work. Should this work?

Was it helpful?

Solution

This is a technique called Server-Side Includes (SSI). It may not be enabled on your web host. If it is, sometimes they force a .shtml extension to be required for included files, so try renaming your file insertthisfile.shtml.

If that doesn't work, you might be able to enable SSIs in a .htaccess file (assuming your web server is Apache). You can find instructions on how to do this by googling. There's a decent set here.

If that fails, I would contact your web host and see if they have SSIs enabled.

OTHER TIPS

Should this work? Perhaps, at some special settings, with some experienced programmer, this could be useful. In my case the include statement seems to be ignored.

I could include some text with

(embed src="include.shtml")
(/embed)

Above, I type () instead of angular brackets.

With the "embed", the setting in the header of the page does not apply to the included text; it should be repeated again, and, by default, the result is ugly. It looks strange, as if the designers of the html did not build-in the very basic tool, the include command. For short articles, the include could save an order of magnitude in the size of files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top