Thursday, January 27, 2005
ContentType problem!
I was working with java servlet that would produce XML document for which I would later apply XSLT
to display the HTML on the client side.
I made a small mistake that was really hard to find out when I was trying on IE.
The IE (I was using) would display XML document by applying XSLT correctly when I requested my server to send the document first two times but when I requested for the third time then the server would send the XML document but now IE would not display it by applying XSLT. :(
Now, I went and checked whether the XML missed out the stylesheet instruction, NO I HAD.
Now, I checked whether the stylesheet is correct and it is pointing to the correct location on server, YES IT IS.
Now, I checked the same application with same actions on Firefox.
Surprised, to see that same action in Firefox would display XML document applying XSLT any number of times I send the request.
Oh, finally I fixed the problem, the server application, that is my java servlet, missed to set the content type of the response, (HttpServletResponse)response.setContentType("text/xml"); and this was the whole cause of the rendering problem.
Now, I was really surprised to see how the first two request was being shown correctly using XSLT and not the third one. :)
to display the HTML on the client side.
I made a small mistake that was really hard to find out when I was trying on IE.
The IE (I was using) would display XML document by applying XSLT correctly when I requested my server to send the document first two times but when I requested for the third time then the server would send the XML document but now IE would not display it by applying XSLT. :(
Now, I went and checked whether the XML missed out the stylesheet instruction, NO I HAD.
Now, I checked whether the stylesheet is correct and it is pointing to the correct location on server, YES IT IS.
Now, I checked the same application with same actions on Firefox.
Surprised, to see that same action in Firefox would display XML document applying XSLT any number of times I send the request.
Oh, finally I fixed the problem, the server application, that is my java servlet, missed to set the content type of the response, (HttpServletResponse)response.setContentType("text/xml"); and this was the whole cause of the rendering problem.
Now, I was really surprised to see how the first two request was being shown correctly using XSLT and not the third one. :)