Hi,
... the servlet engine has to use a certain stream-encoding to communicate to
the client during a connection. This encoding has to be set at the beginning
(see the io-library for more info on this) and remains fixed during the
connection. The servlet engine's io is protected with an internal state :
exceptions are generated if you try to alter things which already have been set
(most notably, when you try to switch from an Printwriter to an outputstream),
depending on the internal state.
So to round things up : every request service you exchange a single element of
data, and the type of the data determines the encoding. It should therefor only
be set once and before you initiate sending data.
Tom John wrote:
> Hi,
>
> What I wan't to know is that by any chance if I want to use the
> setContentType twice How can I do it.It gives (have a look at the following
> code)
> errors but if I pass the res object(which is declared in UdpateExam)as
> getMaxExamId(HttpServletResponse res) it works. Why is that?
>
> Other Question is,
> Let me know what is the meaning of setContentType can be used once. Does it
> to a particular object
> or what.
>
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> class TimeTable{
>
> ....
> ....
>
> //---------------
> public long getMaxExamId() throws ServletException,IOException
> {
> ...
> ...
> HttpServletResponse res1=null;
> res1.setContentType("text");
> PrintWriter out=res.getWriter();
> .......
>
> ......
>
> }
> //----------------
>
> public void UdpateExam(HttpServletResponse res) throws
> ServletException,IOException
> {
> ResultSet rs=null;
> res.setContentType("text/html");
> PrintWriter out=res.getWriter();
>
> ...
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html