I am sending the request from the client (browser) to the server. In Servlet.java file, I am trying to embed html tags in .java files in println,
The above println statment is getting displayed as a string in Mozilla(ver 17.1) whereas I am getting a proper hyperlink in IE( ver 6 ).
What needs to be done to get the same in Mozilla ?
Thanks to all for the support. My clarifications are as follows :
System.out will not send the string to the response.
are you sure it is "System.out.println"?
It is out.println where out is the object to PrintWriter
Is the content type of the servlet output text/html?
I am getting the values from the input type 'text' from html page and updating in the database. The program has got no errors and can update the rows in the db table. The program works correctly in IE and not in Mozilla where out.println("<a href="login.html">Login</a><br>") printing as a string in the html page instead of giving me the hyperlink. The same not happening in IE where I am getting the proper hyperlink.
You need to find out what the content type of the request is. Before knowing that, any other speculation is useless.
Open the debugger in the browser (Chrome's is really good) and look at the network activity. Find the response's content type.
If you are going to be working on the web, these are essential tools you need to know how to use.
John G Wright
Joined: Oct 25, 2012
Please excuse me for lack of knowledge as I am a beginner and for a very very late reply. Thanks for the introduction to Dev Tools in the Chrome Browser.
I figured out the error and it is so simple. By default, Eclipse's internal browser content type set to text/html. So if I try to embed the HTML tags , I am getting the proper HTML output.
But in case of Chrome, the default set content type is plain/text and so if I am not mentioning text/html explicitly as set content type and trying to embed HTML tags say for example out.println("hr") [out being object to printwriter] it is printing as a string instead of HTML page. So if I want to open the link in chrome, I need to set to text/html if I embed HTML tags in servlets.