You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Daniel Strobl <Da...@t-online.de> on 2001/06/12 20:00:15 UTC

AW: java.net.SocketException in Apache + Tomcat configuration.... PLZ HELP !!

this happens if a user uses Internet Explorer and Internet Explorer already
has a resource in cache. IE will simply close the connection, thats what the
message says.

Daniel

-----Ursprüngliche Nachricht-----
Von: Chauhan, Anand [mailto:Anand.Chauhan@iCanSP.com]
Gesendet: Dienstag, 12. Juni 2001 18:39
An: tomcat-user@jakarta.apache.org
Betreff: java.net.SocketException in Apache + Tomcat configuration....
PLZ HELP !!


Hi ALL:

Could y'all please help me with the following errors. Although it doesn't
hamper my flow of logic and control but I was just wondering why it should
ever occur at the first place. My configuration includes Apache Web Server
1.3.14+ and
Tomcat 3.2.1. Here is the exception for your reference:

java.net.SocketException: Connection reset by peer: JVM_recv in socket input
str
eam read
        at java.net.SocketInputStream.socketRead(Native Method)
        at java.net.SocketInputStream.read(Unknown Source)
        at
org.apache.tomcat.service.connector.TcpConnector.receiveFully(TcpConn
ector.java:150)
        at
org.apache.tomcat.service.connector.TcpConnector.receive(TcpConnector
.java:121)
        at
org.apache.tomcat.service.connector.Ajp13ConnectionHandler.processCon
nection(Ajp13ConnectionHandler.java:146)
        at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:
416)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java
:498)

Thanks in advance.

Regards,
Anand Chauhan


Re: Java Question

Posted by Luba Powell <lu...@bellatlantic.net>.
Yes. Monitor lock need to be put on code (preferred) or method wherever they
care accessed by more than one thread.
Example:
static void doSort (int [] arr)
{
    ..
    synchronized(arr)
    {
        // sensitive code
    }
}

.method static doSort([I)V
    aload_0
    monitorenter
    ; sensitive code
    monitorexit
    ...
    return
end method

----- Original Message -----
From: "Brandon Cruz" <bc...@norvax.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, June 12, 2001 2:18 PM
Subject: Java Question


> I have looked all over and can't find the answer to this simple question.
> If you use a static method, do you have to synchronize it in case other
> people may access it at the same time.  For example, I have a static
Utility
> class to do date calculations.  The method Utility.getMonth(String date)
> takes in a full date string, parses it, and returns just the month value.
> If 5 different people all using the website attempt to use
> Utility.getMonth(String date) at the same time for different dates, will
it
> return the right results?  If not, do I have to synchronize it or
something
> in case multiple users attempt to access it?
>
> I know this is not really related to tomcat, but since I am using tomcat,
> and everyone else using tomcat is also a java developer, I figured this is
> the best place I can ask.
>
> Thanks for any help!!!
>
> Brandon
>


RE: Java Question

Posted by Filip Hanik <ma...@filip.net>.
maybe you guys should take this discussion off line or to a general Java
mailing list,
I don't really see how it is relevant to tomcat.

thanks in advance
Filip

~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
filip@filip.net
www.filip.net

>-----Original Message-----
>From: Dmitri Colebatch [mailto:dim@nuix.com.au]
>Sent: Tuesday, June 12, 2001 3:42 PM
>To: tomcat-user@jakarta.apache.org
>Subject: Re: Java Question
>
>
>Correct me if I'm wrong.  But you'd only need to synchronize if the method
>used data that was shared between threads.  If you have a method:
>
>	public static int getMonth(String date)
>	{
>		return dataFormatter.parse(date).get(Calendar.MONTH);
>	}
>
>or something like that (I can never remember the exact api), then you wont
>need to synchronize it because its not using anything (except the
>dateFormatter object) that is shared.  I cant see where you would need
>synchronization there.
>
>The exception to this is the situation where the argument is
>mutable (which
>String is not) and other threads may be changing it, in which case
>you might
>need to synchronize on the argument.  But I cant see why you would
>synchronize a static method as a rule of thumb.  If its a utility method,
>then let the calling class do the synchronization of the data.
>
>I'd like to see someone point out where I am wrong if indeed I am.
>
>thanks
>dim
>
>On Wed, 13 Jun 2001 04:18, Brandon Cruz wrote:
>> I have looked all over and can't find the answer to this simple question.
>> If you use a static method, do you have to synchronize it in case other
>> people may access it at the same time.  For example, I have a static
>> Utility class to do date calculations.  The method
>Utility.getMonth(String
>> date) takes in a full date string, parses it, and returns just the month
>> value. If 5 different people all using the website attempt to use
>> Utility.getMonth(String date) at the same time for different
>dates, will it
>> return the right results?  If not, do I have to synchronize it
>or something
>> in case multiple users attempt to access it?
>>
>> I know this is not really related to tomcat, but since I am using tomcat,
>> and everyone else using tomcat is also a java developer, I
>figured this is
>> the best place I can ask.
>>
>> Thanks for any help!!!
>>
>> Brandon
>


Re: Java Question

Posted by Dmitri Colebatch <di...@nuix.com.au>.
Correct me if I'm wrong.  But you'd only need to synchronize if the method 
used data that was shared between threads.  If you have a method:

	public static int getMonth(String date)
	{
		return dataFormatter.parse(date).get(Calendar.MONTH);
	}

or something like that (I can never remember the exact api), then you wont 
need to synchronize it because its not using anything (except the 
dateFormatter object) that is shared.  I cant see where you would need 
synchronization there.

The exception to this is the situation where the argument is mutable (which 
String is not) and other threads may be changing it, in which case you might 
need to synchronize on the argument.  But I cant see why you would 
synchronize a static method as a rule of thumb.  If its a utility method, 
then let the calling class do the synchronization of the data.

I'd like to see someone point out where I am wrong if indeed I am.

thanks
dim

On Wed, 13 Jun 2001 04:18, Brandon Cruz wrote:
> I have looked all over and can't find the answer to this simple question.
> If you use a static method, do you have to synchronize it in case other
> people may access it at the same time.  For example, I have a static
> Utility class to do date calculations.  The method Utility.getMonth(String
> date) takes in a full date string, parses it, and returns just the month
> value. If 5 different people all using the website attempt to use
> Utility.getMonth(String date) at the same time for different dates, will it
> return the right results?  If not, do I have to synchronize it or something
> in case multiple users attempt to access it?
>
> I know this is not really related to tomcat, but since I am using tomcat,
> and everyone else using tomcat is also a java developer, I figured this is
> the best place I can ask.
>
> Thanks for any help!!!
>
> Brandon

Re: Java Question

Posted by Luba Powell <lu...@bellatlantic.net>.
You are right.  In one case the outcome between native and classic
implementation on locking the class can be different, specifically:
in classic model there is a so tiny chance of missed notification of
monitorenter since it takes dy/dx time to transfer from the wait to
the ready queue.  In all other cases the behavior should be consistent.
But we deviate from tomcat/jsp subjects.  If you want to discuss it
further on machine code level - please contact me directly

----- Original Message -----
From: "Pae Choi" <pa...@earthlink.net>
To: <to...@jakarta.apache.org>
Sent: Tuesday, June 12, 2001 2:59 PM
Subject: Re: Java Question


> You don't seem to understand the relationship between the JVM's
> threads and the native OS's threads.
>
>
> Pae
>
> > Actually the outcome is predictable:
> > monitorenter will obtain objectref on this (aload_0)
> > * if no other thread has locked the object
> > * if the object is currently locked by another thread (monitorenter
> > instruction)
> > * if the current thread already owns a lock - the lock is released when
the
> > counter
> >     returns to 0
> >
> >
> > .method static doSort([I)V
> >     aload_0
> >     monitorenter
> >     ; sensitive code
> >     monitorexit
> >     ...
> >     return
> > end method
> >
> > ----- Original Message -----
> > From: "Brandon Cruz" <bc...@norvax.com>
> > To: <to...@jakarta.apache.org>
> > Sent: Tuesday, June 12, 2001 2:18 PM
> > Subject: Java Question
> >
> > ----- Original Message -----
> > From: "Pae Choi" <pa...@earthlink.net>
> > To: <to...@jakarta.apache.org>
> > Sent: Tuesday, June 12, 2001 2:41 PM
> > Subject: Re: Java Question
> >
> >
> > > When you access the 'synchronized' static method, it locks its class.
> > > so this will ensure the thread-safe access. Otherwise, the result is
> > > unknown.
> > >
> > >
> > > Pae
> > >
> > >
> > > > I have looked all over and can't find the answer to this simple
> > question.
> > > > If you use a static method, do you have to synchronize it in case
other
> > > > people may access it at the same time.  For example, I have a static
> > Utility
> > > > class to do date calculations.  The method Utility.getMonth(String
date)
> > > > takes in a full date string, parses it, and returns just the month
> > value.
> > > > If 5 different people all using the website attempt to use
> > > > Utility.getMonth(String date) at the same time for different dates,
will
> > it
> > > > return the right results?  If not, do I have to synchronize it or
> > something
> > > > in case multiple users attempt to access it?
> > > >
> > > > I know this is not really related to tomcat, but since I am using
> > tomcat,
> > > > and everyone else using tomcat is also a java developer, I figured
this
> > is
> > > > the best place I can ask.
> > > >
> > > > Thanks for any help!!!
> > > >
> > > > Brandon
> > > >
> > >
> >
>


Re: Java Question

Posted by Pae Choi <pa...@earthlink.net>.
You don't seem to understand the relationship between the JVM's
threads and the native OS's threads.


Pae

> Actually the outcome is predictable:
> monitorenter will obtain objectref on this (aload_0)
> * if no other thread has locked the object
> * if the object is currently locked by another thread (monitorenter
> instruction)
> * if the current thread already owns a lock - the lock is released when the
> counter
>     returns to 0
> 
> 
> .method static doSort([I)V
>     aload_0
>     monitorenter
>     ; sensitive code
>     monitorexit
>     ...
>     return
> end method
> 
> ----- Original Message -----
> From: "Brandon Cruz" <bc...@norvax.com>
> To: <to...@jakarta.apache.org>
> Sent: Tuesday, June 12, 2001 2:18 PM
> Subject: Java Question
> 
> ----- Original Message -----
> From: "Pae Choi" <pa...@earthlink.net>
> To: <to...@jakarta.apache.org>
> Sent: Tuesday, June 12, 2001 2:41 PM
> Subject: Re: Java Question
> 
> 
> > When you access the 'synchronized' static method, it locks its class.
> > so this will ensure the thread-safe access. Otherwise, the result is
> > unknown.
> >
> >
> > Pae
> >
> >
> > > I have looked all over and can't find the answer to this simple
> question.
> > > If you use a static method, do you have to synchronize it in case other
> > > people may access it at the same time.  For example, I have a static
> Utility
> > > class to do date calculations.  The method Utility.getMonth(String date)
> > > takes in a full date string, parses it, and returns just the month
> value.
> > > If 5 different people all using the website attempt to use
> > > Utility.getMonth(String date) at the same time for different dates, will
> it
> > > return the right results?  If not, do I have to synchronize it or
> something
> > > in case multiple users attempt to access it?
> > >
> > > I know this is not really related to tomcat, but since I am using
> tomcat,
> > > and everyone else using tomcat is also a java developer, I figured this
> is
> > > the best place I can ask.
> > >
> > > Thanks for any help!!!
> > >
> > > Brandon
> > >
> >
> 

Re: Java Question

Posted by Luba Powell <lu...@bellatlantic.net>.
Actually this instruction is so tiny that you will be OK without
synchronization.

public class StaticTest
{
 synchronized public static String getYear(String str)
 {
     synchronized
   {
       return str.substring(0,4);
    }
  }

 public static void main(String [] args)
 {
  new StaticTest().getYear("abcdefghi");
 }

}

----- Original Message -----
From: "Brandon Cruz" <bc...@norvax.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, June 12, 2001 2:56 PM
Subject: RE: Java Question


> So would changing something simple from...
>
> public static String getYear(String str){
>       newStr = str.substring(0,4);
>       return newStr;
>     }
>
> to...
>
> public static String getYear(String str){
>     synchronized(str){
>       newStr = str.substring(0,4);
>       return newStr;
>     }
>   }
>
> be correct if I want to avoid having incorrect results returned when
> accessed by multiple threads?  It compiles like that, but is that all that
> is needed to synchronize something?
>
> Brandon
>
> -----Original Message-----
> From: Luba Powell [mailto:luba999@bellatlantic.net]
> Sent: Tuesday, June 12, 2001 1:52 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: Java Question
>
>
> Actually the outcome is predictable:
> monitorenter will obtain objectref on this (aload_0)
> * if no other thread has locked the object
> * if the object is currently locked by another thread (monitorenter
> instruction)
> * if the current thread already owns a lock - the lock is released when
the
> counter
>     returns to 0
>
>
> .method static doSort([I)V
>     aload_0
>     monitorenter
>     ; sensitive code
>     monitorexit
>     ...
>     return
> end method
>
> ----- Original Message -----
> From: "Brandon Cruz" <bc...@norvax.com>
> To: <to...@jakarta.apache.org>
> Sent: Tuesday, June 12, 2001 2:18 PM
> Subject: Java Question
>
> ----- Original Message -----
> From: "Pae Choi" <pa...@earthlink.net>
> To: <to...@jakarta.apache.org>
> Sent: Tuesday, June 12, 2001 2:41 PM
> Subject: Re: Java Question
>
>
> > When you access the 'synchronized' static method, it locks its class.
> > so this will ensure the thread-safe access. Otherwise, the result is
> > unknown.
> >
> >
> > Pae
> >
> >
> > > I have looked all over and can't find the answer to this simple
> question.
> > > If you use a static method, do you have to synchronize it in case
other
> > > people may access it at the same time.  For example, I have a static
> Utility
> > > class to do date calculations.  The method Utility.getMonth(String
date)
> > > takes in a full date string, parses it, and returns just the month
> value.
> > > If 5 different people all using the website attempt to use
> > > Utility.getMonth(String date) at the same time for different dates,
will
> it
> > > return the right results?  If not, do I have to synchronize it or
> something
> > > in case multiple users attempt to access it?
> > >
> > > I know this is not really related to tomcat, but since I am using
> tomcat,
> > > and everyone else using tomcat is also a java developer, I figured
this
> is
> > > the best place I can ask.
> > >
> > > Thanks for any help!!!
> > >
> > > Brandon
> > >
> >
>
>


RE: Java Question

Posted by Milt Epstein <me...@uiuc.edu>.
On Tue, 12 Jun 2001, Brandon Cruz wrote:

> So would changing something simple from...
>
> public static String getYear(String str){
>       newStr = str.substring(0,4);
>       return newStr;
>     }
>
> to...
>
> public static String getYear(String str){
>     synchronized(str){
>       newStr = str.substring(0,4);
>       return newStr;
>     }
>   }
>
> be correct if I want to avoid having incorrect results returned when
> accessed by multiple threads?  It compiles like that, but is that
> all that is needed to synchronize something?

I hate to reply to an off-topic post, but I think some of what's been
said so far has been inaccurate/misleading.  There's nothing special
about static methods when it comes to synchronization.  It all depends
what the method is doing, what kind of resources it's using, what
kinds of variables it's using (e.g. class, instance, local), as to
whether it needs to be synchronized.

In the above code, you reference the variable newStr, but it's
declaration is not shown.  Does that mean it's a class variable?  Why?
Does it need to be?  There's nothing in the code you show that makes
it necessary for it to be a class variable.  Class variable can get
you in trouble with threading issues.  If possible, make it a local
variable, as such:

  public static String getYear(String str) {
    String newStr = str.substring(0,4);
    return newStr;
  }

Now, this method does not need to be synchronized (whether it's static
or not).  All the variables are local, so there won't be any threading
issues.

Furthermore, when you do synchronize, be careful what object you
synchronize on.  For example, suppose there was some legitimate reason
that newStr had to be a class variable, and you did need to
synchronize changes to it.  You don't want to sync on str, because
that is a parameter (essentially a local variable), and will be
different on all calls to getYear().  Remember, you don't sync on a
variable name, you sync on an object.  You could sync the entire
method, which would take care of it, but that may be too large a scope
to sync on.  Another alternative would be create a class variable and
sync on that, as such:

  private static Object getYearSync = new Object();

  ...

  public static String getYear(String str) {
    synchronize(getYearSync) {
      String newStr = str.substring(0,4);
      return newStr;
    }
  }

(Note: Code not tested :-).


[ ... ]
> ----- Original Message -----
> From: "Brandon Cruz" <bc...@norvax.com>
> To: <to...@jakarta.apache.org>
> Sent: Tuesday, June 12, 2001 2:18 PM
> Subject: Java Question
>
> ----- Original Message -----
> From: "Pae Choi" <pa...@earthlink.net>
> To: <to...@jakarta.apache.org>
> Sent: Tuesday, June 12, 2001 2:41 PM
> Subject: Re: Java Question
>
>
> > When you access the 'synchronized' static method, it locks its class.
> > so this will ensure the thread-safe access. Otherwise, the result is
> > unknown.
> >
> >
> > > I have looked all over and can't find the answer to this simple
> > > question.  If you use a static method, do you have to
> > > synchronize it in case other people may access it at the same
> > > time.  For example, I have a static Utility class to do date
> > > calculations.  The method Utility.getMonth(String date) takes in
> > > a full date string, parses it, and returns just the month value.
> > > If 5 different people all using the website attempt to use
> > > Utility.getMonth(String date) at the same time for different
> > > dates, will it return the right results?  If not, do I have to
> > > synchronize it or something in case multiple users attempt to
> > > access it?
> > >
> > > I know this is not really related to tomcat, but since I am
> > > using tomcat, and everyone else using tomcat is also a java
> > > developer, I figured this is the best place I can ask.
> > >
> > > Thanks for any help!!!
[ ... ]

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
mepstein@uiuc.edu


RE: Java Question

Posted by Brandon Cruz <bc...@norvax.com>.
So would changing something simple from...

public static String getYear(String str){
      newStr = str.substring(0,4);
      return newStr;
    }

to...

public static String getYear(String str){
    synchronized(str){
      newStr = str.substring(0,4);
      return newStr;
    }
  }

be correct if I want to avoid having incorrect results returned when
accessed by multiple threads?  It compiles like that, but is that all that
is needed to synchronize something?

Brandon

-----Original Message-----
From: Luba Powell [mailto:luba999@bellatlantic.net]
Sent: Tuesday, June 12, 2001 1:52 PM
To: tomcat-user@jakarta.apache.org
Subject: Re: Java Question


Actually the outcome is predictable:
monitorenter will obtain objectref on this (aload_0)
* if no other thread has locked the object
* if the object is currently locked by another thread (monitorenter
instruction)
* if the current thread already owns a lock - the lock is released when the
counter
    returns to 0


.method static doSort([I)V
    aload_0
    monitorenter
    ; sensitive code
    monitorexit
    ...
    return
end method

----- Original Message -----
From: "Brandon Cruz" <bc...@norvax.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, June 12, 2001 2:18 PM
Subject: Java Question

----- Original Message -----
From: "Pae Choi" <pa...@earthlink.net>
To: <to...@jakarta.apache.org>
Sent: Tuesday, June 12, 2001 2:41 PM
Subject: Re: Java Question


> When you access the 'synchronized' static method, it locks its class.
> so this will ensure the thread-safe access. Otherwise, the result is
> unknown.
>
>
> Pae
>
>
> > I have looked all over and can't find the answer to this simple
question.
> > If you use a static method, do you have to synchronize it in case other
> > people may access it at the same time.  For example, I have a static
Utility
> > class to do date calculations.  The method Utility.getMonth(String date)
> > takes in a full date string, parses it, and returns just the month
value.
> > If 5 different people all using the website attempt to use
> > Utility.getMonth(String date) at the same time for different dates, will
it
> > return the right results?  If not, do I have to synchronize it or
something
> > in case multiple users attempt to access it?
> >
> > I know this is not really related to tomcat, but since I am using
tomcat,
> > and everyone else using tomcat is also a java developer, I figured this
is
> > the best place I can ask.
> >
> > Thanks for any help!!!
> >
> > Brandon
> >
>



Re: Java Question

Posted by Luba Powell <lu...@bellatlantic.net>.
Actually the outcome is predictable:
monitorenter will obtain objectref on this (aload_0)
* if no other thread has locked the object
* if the object is currently locked by another thread (monitorenter
instruction)
* if the current thread already owns a lock - the lock is released when the
counter
    returns to 0


.method static doSort([I)V
    aload_0
    monitorenter
    ; sensitive code
    monitorexit
    ...
    return
end method

----- Original Message -----
From: "Brandon Cruz" <bc...@norvax.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, June 12, 2001 2:18 PM
Subject: Java Question

----- Original Message -----
From: "Pae Choi" <pa...@earthlink.net>
To: <to...@jakarta.apache.org>
Sent: Tuesday, June 12, 2001 2:41 PM
Subject: Re: Java Question


> When you access the 'synchronized' static method, it locks its class.
> so this will ensure the thread-safe access. Otherwise, the result is
> unknown.
>
>
> Pae
>
>
> > I have looked all over and can't find the answer to this simple
question.
> > If you use a static method, do you have to synchronize it in case other
> > people may access it at the same time.  For example, I have a static
Utility
> > class to do date calculations.  The method Utility.getMonth(String date)
> > takes in a full date string, parses it, and returns just the month
value.
> > If 5 different people all using the website attempt to use
> > Utility.getMonth(String date) at the same time for different dates, will
it
> > return the right results?  If not, do I have to synchronize it or
something
> > in case multiple users attempt to access it?
> >
> > I know this is not really related to tomcat, but since I am using
tomcat,
> > and everyone else using tomcat is also a java developer, I figured this
is
> > the best place I can ask.
> >
> > Thanks for any help!!!
> >
> > Brandon
> >
>


Re: Java Question

Posted by Pae Choi <pa...@earthlink.net>.
When you access the 'synchronized' static method, it locks its class.
so this will ensure the thread-safe access. Otherwise, the result is
unknown.


Pae


> I have looked all over and can't find the answer to this simple question.
> If you use a static method, do you have to synchronize it in case other
> people may access it at the same time.  For example, I have a static Utility
> class to do date calculations.  The method Utility.getMonth(String date)
> takes in a full date string, parses it, and returns just the month value.
> If 5 different people all using the website attempt to use
> Utility.getMonth(String date) at the same time for different dates, will it
> return the right results?  If not, do I have to synchronize it or something
> in case multiple users attempt to access it?
> 
> I know this is not really related to tomcat, but since I am using tomcat,
> and everyone else using tomcat is also a java developer, I figured this is
> the best place I can ask.
> 
> Thanks for any help!!!
> 
> Brandon
> 

RE: Java Question

Posted by Brandon Cruz <bc...@norvax.com>.
Thank you everyone for your help!  It has been VERY helpful to see
everyone's opinion and share knowledge on the topic of static methods and
synchronization.  I think many people have learned alot from this thread.  I
understand it was off topic, but sometimes the best way to get an answer is
to ask the community of JAVA DEVELOPERS you are familiar with.  Kind of like
asking a question of someone at work who will know the answer, but is not
working on your specific project.  Jan, I'm sure I offended you by starting
this thread, just like the ten other people you have so scolded in the past
week.  I'm sorry!

Thanks again for everyone's help!

Brandon

-----Original Message-----
From: Hemant Singh [mailto:hemant111in@yahoo.com]
Sent: Tuesday, June 12, 2001 11:22 PM
To: tomcat-user@jakarta.apache.org
Subject: Re: Java Question


HI Bran:
There is no relation betn static and synchronize

If you are synchronizing the static method than it
does means you are giving him the class level lock,
and not instance level lock.
Hope that help
Regards
Hemant

--- Brandon Cruz <bc...@norvax.com> wrote:
> I have looked all over and can't find the answer to
> this simple question.
> If you use a static method, do you have to
> synchronize it in case other
> people may access it at the same time.  For example,
> I have a static Utility
> class to do date calculations.  The method
> Utility.getMonth(String date)
> takes in a full date string, parses it, and returns
> just the month value.
> If 5 different people all using the website attempt
> to use
> Utility.getMonth(String date) at the same time for
> different dates, will it
> return the right results?  If not, do I have to
> synchronize it or something
> in case multiple users attempt to access it?
>
> I know this is not really related to tomcat, but
> since I am using tomcat,
> and everyone else using tomcat is also a java
> developer, I figured this is
> the best place I can ask.
>
> Thanks for any help!!!
>
> Brandon
>


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year!  http://personal.mail.yahoo.com/


Re: Java Question

Posted by Hemant Singh <he...@yahoo.com>.
HI Bran:
There is no relation betn static and synchronize

If you are synchronizing the static method than it
does means you are giving him the class level lock,
and not instance level lock.
Hope that help
Regards
Hemant

--- Brandon Cruz <bc...@norvax.com> wrote:
> I have looked all over and can't find the answer to
> this simple question.
> If you use a static method, do you have to
> synchronize it in case other
> people may access it at the same time.  For example,
> I have a static Utility
> class to do date calculations.  The method
> Utility.getMonth(String date)
> takes in a full date string, parses it, and returns
> just the month value.
> If 5 different people all using the website attempt
> to use
> Utility.getMonth(String date) at the same time for
> different dates, will it
> return the right results?  If not, do I have to
> synchronize it or something
> in case multiple users attempt to access it?
> 
> I know this is not really related to tomcat, but
> since I am using tomcat,
> and everyone else using tomcat is also a java
> developer, I figured this is
> the best place I can ask.
> 
> Thanks for any help!!!
> 
> Brandon
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

RE: Tomcat integration w/ IIS 4.0

Posted by Kevin Queen <kq...@anydevice.com>.
List,
This is a repost so if you are getting this twice, I appologize.  I am new to Tomcat and have what I
hope is a simple question.  I have a servlet that parses an xml file and then formats the output,
what I want to do is be able to call http://server.com/myServlet/index.xml and have Tomcat invoke
the servlet in the myServlet and output the parsed and formatted page. Now I CAN call
http://server.com:8080/myServlet/index.xml and it all works fine.  I have added the following lines
to the following files:

uriworkermap.properties:
/myServlet/*=$(default.worker)

web.xml:
<servlet>
<servlet-name>myServlet</servlet-name>
<servlet-class>com.myServlet.engine.EngineServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>myServlet</servlet-name>
<url-pattern>/myServlet</url-pattern>
</servlet-mapping>

Here is my server setup:
Win NT 4.0 SP6a
256 MB Ram
IIS 4
isapi redirector is installed and working (I can do JSP and the example servlets)
Tomcat is NOT running as a service (though I would like to)
Tomcat 3.2.2

Any and all help will be much appreciated.

Thanks,
Kevin Queen



Tomcat integration w/ IIS 4.0

Posted by Kevin Queen <kq...@anydevice.com>.
List,
I am new to Tomcat and have what I hope is a simple question.  I have a servlet that parses an xml
file and then formats the output, what I want to do is be able to call
http://server.com/myServlet/index.xml and have Tomcat invoke the servlet in the myServlet and output
the parsed and formatted page. Now I CAN call http://server.com:8080/myServlet/index.xml and it all
works fine.  I have added the following lines to the following files:

uriworkermap.properties:
/myServlet/*=$(default.worker)

web.xml:
<servlet>
<servlet-name>myServlet</servlet-name>
<servlet-class>com.myServlet.engine.EngineServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>myServlet</servlet-name>
<url-pattern>/myServlet</url-pattern>
</servlet-mapping>

Here is my server setup:
Win NT 4.0 SP6a
256 MB Ram
IIS 4
isapi redirector is installed and working (I can do JSP and the example servlets)
Tomcat is NOT running as a service (though I would like to)
Tomcat 3.2.2

Any and all help will be much appreciated.

Thanks,
Kevin Queen


Java Question

Posted by Brandon Cruz <bc...@norvax.com>.
I have looked all over and can't find the answer to this simple question.
If you use a static method, do you have to synchronize it in case other
people may access it at the same time.  For example, I have a static Utility
class to do date calculations.  The method Utility.getMonth(String date)
takes in a full date string, parses it, and returns just the month value.
If 5 different people all using the website attempt to use
Utility.getMonth(String date) at the same time for different dates, will it
return the right results?  If not, do I have to synchronize it or something
in case multiple users attempt to access it?

I know this is not really related to tomcat, but since I am using tomcat,
and everyone else using tomcat is also a java developer, I figured this is
the best place I can ask.

Thanks for any help!!!

Brandon