Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Servlet output in IE (http://www.velocityreviews.com/forums/t297856-servlet-output-in-ie.html)

Sameer 06-08-2006 08:14 AM

Servlet output in IE
 
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.


Andrea Desole 06-08-2006 09:09 AM

Re: Servlet output in IE
 
Sameer wrote:
>
> 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.


asaguden 06-08-2006 11:29 AM

Re: Servlet output in IE
 
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
Sameer wrote:
> 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.




All times are GMT. The time now is 12:35 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.