Am I correct in assuming that both

count++;

and

System.out.println(count);

need to be synchronized in order to guarantee that the right request prints
the right value of count?

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Saumont Pierre-Yves
Sent: Friday, April 20, 2001 5:15 PM
To: [EMAIL PROTECTED]
Subject: Re: [Re: Servlets constructors]


Hey Mark, why do you need to use init() when you can do :

import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;

public class CounterCons extends HttpServlet {
        int count = 1122;
        public void doGet(HttpServletRequest req,HttpServletResponse res)
throws
IOException {
                PrintWriter out=res.getWriter();
                count++;
                out.println(count);
        }
}

That's not exactly the same, but it's probably close enough to what he
want's !

BTW, Mark, how is your mail program configured ? Replies to your messages
are sent to you and not to the list. May be that's why you get so many
private questions !

Pierre-Yves


-----Message d'origine-----
De : A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]De la part de
balwinder singh
Envoyé : samedi 21 avril 2001 00:01
À : [EMAIL PROTECTED]
Objet : Re: [Re: Servlets constructors]


My question is :
 If I want to start my counter(see code below) with a default value (say
1122)
then if i use constructor of
 my servlet to do this, what is wrong with the code?why cant i use
construtor
in this way in servlets?



import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;

public class CounterCons extends HttpServlet
 {
    int count;


     CounterCons(int i)
      {
        count=i;
      }
    public void doGet(HttpServletRequest req,HttpServletResponse res) throws
IOException
     {
       new CounterCons(1122);
       PrintWriter out=res.getWriter();
       count++;
       out.println(count);
     }

 }



















"T.A. Flores" <[EMAIL PROTECTED]> wrote:
So what exactly is your question?


----- Original Message -----
From: balwinder singh <[EMAIL PROTECTED]>
Date: Friday, April 20, 2001 2:03 pm
Subject: Servlets constructors

> Hi
> I am new to Servlets and a lil curious about this question:
>
> The problem is:
>
>     In JDK1.1 servlet Constructor were not allowed.But are they
> allowed in
> JDK1.3?
>     If no,then why not? and if yes then pls give an example.
> Regards
> Balwinder Singh
> web developer
>
>
> ____________________________________________________________________
> Get free email and a permanent address at
> http://www.netaddress.com/?N=1
>
________________________________________________________________________
___
> To unsubscribe, send email to [EMAIL PROTECTED] and include in
> the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http:
> Resources: http://java.sun.com/products/servlet/external-
> resources.htmlLISTSERV 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


____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

___________________________________________________________________________
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

___________________________________________________________________________
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

Reply via email to