Servlet output in IE

S

Sameer

Hello,
I have the following servlet code:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World\n");
out.println("Hello World\n");
out.println("Hello World\n");
out.println("Hello World\n");
}
}

The first time I execute the servlet, it gives me the output:
Hello World Hello World Hello World Hello World
i.e. all the text in a single line.
Please note that no HTML code is embedded in the servlet.

The next time I refresh the same page, the output is:


Hello World

Hello World

Hello World

Hello World

Why this may be happening?
Please clarify.
 
A

Andrea Desole

Sameer said:
The first time I execute the servlet, it gives me the output:
Hello World Hello World Hello World Hello World
i.e. all the text in a single line.
Please note that no HTML code is embedded in the servlet.

The next time I refresh the same page, the output is:


Hello World

Hello World

Hello World

Hello World

Why this may be happening?
Please clarify.

what you have to look at is not only what you put in your response, but
also how the browser interprets it. To know that you can look at the
content type. If you don't set the content type I believe there is no
content type header sent to the client, which makes explorer free to
interpret it.
The fact that you see it in different ways is probably a bug, I assume
related to the fact that the second time the file is probably read from
the cache.
 
A

asaguden

I agree with Andrea. but I have a tip, try the same with Firefox.
And turn off your web site cache.

( IE ususally assumes whats coming is HTML, but Firefox doesnt.
Which means that if you dont specify the output there will be a
difference )

/ Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top