when i execute this servlet, why the doGet()method is always invoked even though this method is not explicitly called? I know when a form is submitted, a method attribute value is set either GET or POST that makes either doGet() or doPost() being called accordingly. but when GET or POST is not explicitly called like i execute a above servlet, what makes the doGet() method of the servlet invoked and why not doPost()? please clarify me this mechanism. And Also, why does setContentType("text/html") have to be present? can't we do without it? I tried running above servlet without it, bud didn't see any problem?When does it cause a problem without it? thanks. [ September 09, 2003: Message edited by: Namaste Sathi ] [ September 13, 2003: Message edited by: Jim Yingst ]
the default contentType for a response is text/html. This is not necessary and does not affect your code if you do not have it but it will be helpful while reviewing your code if you set different response contentTypes through out your application e.g. text/xml, etc. Thank you, Maneesh
Sun Certified Java Programmer 2 (1.4)<br />Sun Certified Web Component Developer
Originally posted by maneesh subherwal: the default contentType for a response is text/html. This is not necessary and does not affect your code if you do not have it but it will be helpful while reviewing your code if you set different response contentTypes through out your application e.g. text/xml, etc. Thank you, Maneesh
i am not sure how setContentType will be helpful while reviewing code if it does not matter setContentType is set or not. can you please clarify this in a bit detail? thanks.
posted 16 years ago
I believe that setting the content-type is only unnecessary in the case where html is expected to be displayed since the default is text/html. it is necessary in other cases, such as image/gif, etc. The setContentType method sets the MIME type (Multipurpose Internet Mail Extensions) of the response. Many MIME types currently exist other than the ones mentioned here. While reviewing code and for developers who are unsure of what the default content type is, it is good to explicitly set it in the code even if the response is in text/html. I hope this helps... Thank you, Maneesh
today's feeble attempt to support the empire
Devious Experiments for a Truly Passive Greenhouse!