I am having trouble serving more than the index file from SD card on a w5100

Problem Description: I am trying to serve an index file (possessing the outline of a menu) and the accompanying .css and .js file. However when I use a webserver example that serves the index.htm off the SD card it behaves as though its a bare index file all by itself. I have shortened the names to 8.3 just in case that was the issue but it did not.

Does anybody know what I might be missing?
here is my html for the menu

Test Menu

Here is a link to my server code on the playground. The first example on that page serves several file types from the SD card. Take a look at it and it may help you make some sense about what is required. http://playground.arduino.cc/Code/WebServerST

The files must be 8.3 format.

I do apologize but I have looked at the playground code quite a bit and it is well above my head. I know basic arduino commands and very basic HTML (I used wizards and generators mostly) but this appears beyond me. Is there anything explicit you can point out for me, this is my code to serve the index.

Here is the code I am using for serving the index page.

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

// MAC address from Ethernet shield sticker under board
byte mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10, 0, 0, 20); // IP address, may need to change depending on network
EthernetServer server(80); // create a server at port 80

File webFile;

void setup()
{
Ethernet.begin(mac, ip); // initialize Ethernet device
server.begin(); // start to listen for clients
Serial.begin(9600); // for debugging

// initialize SD card
Serial.println(“Initializing SD card…”);
if (!SD.begin(4)) {
Serial.println(“ERROR - SD card initialization failed!”);
return; // init failed
}
Serial.println(“SUCCESS - SD card initialized.”);
// check for index.htm file
if (!SD.exists(“index.htm”)) {
Serial.println(“ERROR - Can’t find index.htm file!”);
return; // can’t find index file
}
Serial.println(“SUCCESS - Found index.htm file.”);
}

void loop()
{
EthernetClient client = server.available(); // try to get client

if (client) { // got client?
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) { // client data available to read
char c = client.read(); // read 1 byte (character) from client
// last line of client request is blank and ends with \n
// respond to client only after last line received
if (c == ‘\n’ && currentLineIsBlank) {
// send a standard http response header
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(“Connection: close”);
client.println();
// send web page
webFile = SD.open(“index.htm”); // open web page file
if (webFile) {
while(webFile.available()) {
client.write(webFile.read()); // send web page to client
}
webFile.close();
}
break;
}
// every line of text received from the client ends with \r\n
if (c == ‘\n’) {
// last character on line of received text
// starting new line with next character read
currentLineIsBlank = true;
}
else if (c != ‘\r’) {
// a text character was received from client
currentLineIsBlank = false;
}
} // end if (client.available())
} // end while (client.connected())
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection
} // end if (client)
}

That should do it, but if you are using the index.htm file in the original post above, it won't work. The reason is you are expecting the web browser to download two more files from the Arduino, the mbb.css file and the mbj.js file. Your code doesn't allow for those file downloads.

You also must close the connection from the server end when you are done sending. After the webFile.close() call, add a client.stop() call.

Thank-you very much! That certainly narrows it down for me!

The code I posted in reply #1 has all that stuff. It closes the connection, and allows for downloads of both those file types, plus many more, like gif, jpg and ico files.