Link to home
Start Free TrialLog in
Avatar of Dr. Klahn
Dr. Klahn

asked on

SHTML Javascript fails to display image under Apache 2.4

After upgrading a very small server from Apache 2.2 to Apache 2.4, some images called from an included file no longer appear on the page.

The host uses scripted HTML.  The SHTML files include an HTML header template.  I have confirmed that the HTML header is being included properly in the outgoing and received SHTML file.

As a source file on the server (trimmed for brevity):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<TITLE>domainname.com</title>
<META NAME="description" CONTENT="bla bla bla.">
</HEAD>

<BODY BGCOLOR="#FFD700">

<!--#include virtual="/includes/StandardHeader.html" -->

<!-- Content section begins here, below the header -->
(file continues) ...

Open in new window


As received by Firefox:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<TITLE>domainname.com</title>
<META NAME="description" CONTENT="bla bla bla.">
</HEAD>

<BODY BGCOLOR="#FFD700">

<!-- Included header file to be inserted below BODY -->

<DIV ID="header">

<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#6699FF"><TR>
<TD>
<script type="text/javascript">
<!--
 var image_number = 0;
 var image_count = 12;
  function randomimage() {
        image_number = 1 + Math.floor(Math.random() * image_count);
        return image_number;
    }
  document.write("<img src='http://www.mydomainname.com/headerimages/header" + randomimage() + ".png'>");
//-->
</script></TD>
<TD><IMG SRC="http://www.mydomainname.com/headerimages/hnheader.png"></TD>
</TR></TABLE>

<P>&nbsp;</P>

</DIV>

<!-- End of included header file.  Content follows. -->



<!-- Content section begins here, below the header -->

<DIV ID="body">
<hr COLOR="#FFD700">

<center><IMG SRC="image.png" ALT="bla bla bla"></CENTER>

<P>&nbsp;</P>
<CENTER><A HREF="somedirectory/index2.shtml"><IMG SRC="somedirectory/SeeMoreButton.png" BORDER="0"></A></CENTER>
<P>&nbsp;</P>
</DIV>

<!-- End of the content section -->

</BODY>
</HTML>

Open in new window


The issue does not appear to be in the Apache server as it serves up images correctly and properly includes the HTML header file.

This SHTML source file is unchanged from the Apache 2.2 server where it worked properly.

It is not an access privileges problem because the second image displays properly, and both the random and fixed images reside in the same directory.

It is interesting that the second image in the header table ("hnheader.png") appears quite properly in the correct place.  So I am tempted to say that this is a Javascript issue, were it not for the fact that I have another site using the same server and essentially the same include ... which works properly.

Insights will be gratefully received.
Avatar of David Favor
David Favor
Flag of United States of America image

You're fighting several battles here.

1) Going from 2.2 -> 2.4 requires changing some config directives. If you missed changing this for location of your problem images, and this might be the problem.

2) If you .shtml files are actually included, then most likely mod_include is working correctly, and this might be a problem.

3) Some of your images have absolute paths. Some have relative paths. An incorrect image path might be the problem.

The real answer will live in your Apache error.log + access.log files, so that's the first place to look.

If you require more detailed answers provide a clickable URL for your page, along with the name of the exact problem image... so image file name, rather than "second image" or some image number.

The clickable URL will be required for best answers.

Also attach a copy of your current access.log + error.log Apache log files.
Avatar of Dr. Klahn
Dr. Klahn

ASKER

Thanks, David.  The Apache logfiles are empty except for the SHTML and image file requests.  No errors are being logged.  The request for the SHTML file is succeeding with the correct size.  The request for the randomly selected image is not being logged.

The config files have been changed to reflect the change from 2.2 to 2.4, using a similar system running 2.4 as the template.

I will forward you a URL as a PM so that you can have a look at the situation.

Further information:

The Apache logs show that all the requests, both images and SHTML, are coming through -- with the sole exception being the one generated by the Javascript.  This suggests to me that there is an issue in the Javascript, though it was previously working correctly.

xx.xx.xx.171  Feb 22 22:18:31  200  1331 bytes
  "GET /index.shtml HTTP/1.1"  Mozilla/5.0 (Windows NT 9.1; rv:82.0) Gecko/20100101 Firefox/82.0
xx.xx.xx.171  Feb 22 22:18:32  304  - bytes
  "GET /headerimages/hnheader.png HTTP/1.1"  Mozilla/5.0 (Windows NT 9.1; rv:82.0) Gecko/20100101 Firefox/82.0
xx.xx.xx.171  Feb 22 22:18:32  304  - bytes
  "GET /somedirectory/SeeMoreButton.png HTTP/1.1"  Mozilla/5.0 (Windows NT 9.1; rv:82.0) Gecko/20100101 Firefox/82.0
xx.xx.xx.171  Feb 22 22:18:32  304  - bytes
  "GET /image.png HTTP/1.1"  Mozilla/5.0 (Windows NT 9.1; rv:82.0) Gecko/20100101 Firefox/82.0

Open in new window

Hi there,

You haven't really said exactly what you mean by 'the image isn't showing'. Do you get an <img> tag in your page, but with a broken icon, or do you get nothing in the page?

I would suggest checking the console initially. Press F12 in Firefox to bring up the developer tools. Then load up your page. Check the console tab to see if there are an Javascript errors. Check the Network tab to see if there are any 404 errors. That should at least narrow down where the problem lies - either the JS has a problem or the image can't be found. Once you know that, you can start to debug the problem
ASKER CERTIFIED SOLUTION
Avatar of Dr. Klahn
Dr. Klahn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial