In IE7 servlet generated html loses CSS formatting

Hi.

I am generating html within my servlet and building a string containing html - a few <TD> tags with dynamic database data in them(shown below). When using firefox this generated html works perfectly and inherits the css formatting from the calling JSP page. However with IE7 the formatting is lost and the data is presented with no formatting.

Put simply firefox displays the servlet generated html using my css formatting, but IE7 does not. I tried including the stylesheet link ref in the generated html, this didn't work - any help much appreciated, code below:

String message ="<link href=\"/stylesheet/myForm.css\" rel=\"stylesheet\" type=\"text/css\"/>";

for(int i=0;i<list.size();i++)

{

myclass = (myclass) lest.get(i);

message +="<tr><th>QN</th><td>" + myclass.getMethod() +"></td>" ;

}

response.setContentType("text/html");

response.setContentLength(message.length());

PrintWriter pw = response.getWriter();

pw.write(message);

pw.close();

pw.flush();

The response is the written to div innerHTML using javascript...

var response = xmlHttp.responseText;

document.getElementById("mydiv").innerHTML = response;

document.getElementById("mydiv").style.display ="block";

Works perfectly using firefox but not with IE7, do I have to change.

Thanks a lot.

Cheers BT.

[1730 byte] By [bat-thinka] at [2007-11-27 10:32:39]
# 1

1- look at the source code of your IE7 web page and find out the css link.

2- try this link: http://YOUR_SERVER:YOUR_SERVER_POR_NUMBER/YOUR_APP_NAME/stylesheet/myForm.css

example: http://127.0.0.1:8080/YOUR_APP_NAME/stylesheet/myForm.css

java_2006a at 2007-7-28 18:17:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hi.

Thanks for the input however I have now solved the problem. Previously I was *not* generating the table tag server side, it was part of the calling jsp page and I was only generating tr and td tags in the servlet. I changed this so that the table tag was also part of the html string generated within the servlet. It now works perfectly on both browsers (ie7 and ff).String message = "<table width=\"90%\">";

for(int i=0;i<list.size();i++)

{

myclass = (myclass) lest.get(i);

message += "<tr><th>QN</th><td>" + myclass.getMethod() + "></td>" ;

}

message += "</td></tr></table>";

response.setContentType("text/html");

response.setContentLength(message.length());

PrintWriter pw = response.getWriter();

pw.write(message);

pw.close();

pw.flush();

bat-thinka at 2007-7-28 18:17:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...