JSP Insider - http://www.jspinsider.com

News - Articles/Tutorials/Code/Reviews - JSP/Servlet Hosting Companies - Links

JSPBuzz Vol I: Issue 5 -- 9/19/2000

HTTP://WWW.JSPInsider.com/

***** IN THIS ISSUE ************************************************** 
1:SUN Posts Public Draft of JDBC 3.0
2:SUN Posts Public Draft of Enterprise JavaBeans 2.0
3:Gartner Predicts .Net and Java Will Rule

Rambles 
1:Java User Groups
1:The CLEANS Award (the best and worst of software/standards)
	
Links 	
1:WML, the Language of the Wireless Web
2:Introduction to XHTML
3:Zaplets
4:JavaServer Pages Fundamentals
5:The Java Performance Report:  Part 3 
6:SOAP (Simple Object Access Protocol) 

Main Topic 
1:Death by Synchronization

Like this newsletter? Tell a friend about the JSP Buzz!

================================================================
              THE LATEST NEWS
================================================================

1) SUN Posts Public Draft of JDBC 3.0  (SUN 09/12/2000)
SUN started the public review of the JDBC 3.0 specifications.
Some of the new features JDBC 3.0 will add include Blob column 
updates, Boolean data types, improved connection pooling support, 
retrieval of auto generated keys and support for external datasources.
Public review closes October 12, 2000. 

2) SUN Posts Public Draft of Enterprise JavaBeans 2.0 (SUN 09/12/2000)
Public review of Sun's EJB 2.0 specifications is also underway. 
If you are interested, review the transcripts of the Chat 
(held on 9/19/2000) about EJB 2.0  at the following address:
http://developer.java.sun.com/developer/community/chat/index.html
Public review closes October 12, 2000.
 
3) Gartner Predicts .Net and Java Will Rule (9/11/2000)
Gartner forecasts Microsoft's .Net platform and Sun's Java will
be the two primary tools for Internet application development. Not a 
shocking prediction. More surprising is they are also predicting
Java will lose the lead in the handheld device arena.


================================================================
  Rambles by Casey Kochmer
================================================================

************************   Java User Groups ************************ 

One of the best things about Java is the truly international 
representation of programmers. Java groups are forming all over the 
world and making their presence known on the web. This means you may 
easily swap notes with someone in India, New Zealand, Italy or just 
around the corner. Currently 530 user groups are in existence and 1300 
more are forming! So if you are interested in meeting a fellow Java 
programmer, the world is yours to roam literally only a mouse click away!


Some of my favorite Java user group sites are:
 
JUG CCM (Mexico)

Javaesque (Singapore)

Ames Java User Group (United States)

BEJUG (Belgium)

If you want a more comprehensive list of sites to visit see the SUN site.


************************ The CLEANS Award *************************** 
********** (the best and worst of software/standards) ***************

I had an acronym overload today.  After a few moments pondering,
I decided to join the acronym bandwagon.  The result is the 
CLEANS Award (Confuse Literally Everyone Accessing Needed Software). 
Is there a standards body that maintains acronyms?  Maybe I should submit 
this one. 

If you too have suffered from some software standard that should never 
have been created or have spent hours frustrated with some software 
package you can't use since it is so confusing, then nominate your 
least favorite software or standard offender for a CLEANS Award.  On 
the flip side, if you know of a standard which has gone above and 
beyond being a mere acronym or a piece of software that is truly easy
to use, we want to know. 

Submit your nominations to the JSP Buzz. Include the name of your 
entry along with your list of peeves or praises.  We will not publish 
the name of anyone submitting an entry.  The prize will be the 
satisfaction of airing your grievances or kudos to the world.

After a few hundred replies are received, CLEANS Award results for the 
five best and five worst nominations will be published in the JSP Buzz.  
Stay tuned.  The CLEANS certification process is now open!


================================================================
              Links of Interest
================================================================

[Article] WML, the Language of the Wireless Web (Troy Dreier )
The Internet is all about communication -- and communication methods 
are expanding on all fronts of society  Some days you just feel like 
road-kill, run over by yet another new method for swapping information. 
WML, WAP and the wireless Internet are all part of this frenzy to develop 
new ways to communicate.  This article gives a simple overview of these 
wireless technologies and where they're all heading.  In summary, here's 
one more reason to begin learning XHTML. XHTML you ask? Yes, the world 
of HTML is expanding to include XHTML, but also WML as well!

[Article] Introduction to XHTML  (Alan Richmond 2/2/2000)
Having mentioned XHTML, it would be unfair not to add a link to
some more information on it.  Over the next few years XHTML will 
slowly replace HTML.  In fact, XHTML may really be thought of as 
HTML 5.0.  So getting to know XHTML now and revising your current 
HTML programming habits will be of great benefit for you in the long 
term. As an example to show that XHTML is ready for prime time, this 
link site is built entirely in XHTML.

[New Product] Zaplets (Company: FireDrop)
In the theme of ever expanding communication tools, now add 
zaplet to your vocabulary. A zaplet is interactive email. When
you respond to a zaplet, a centralized server is updated, allowing
everyone to share in your response. Zaplets originate from several
of the gurus who helped make Java a reality. Zaplet will undoubtedly
become a new buzz word and, I suspect, as common as the Post-It note 
in the offices of the world.  Some additional materials about zaplets 
comes from ZDnet.

[Tutorial] JavaServer Pages Fundamentals (JGuru 9/13/2000)
A nice tutorial to help you learn JavaServer Pages. It reviews
many basic JSP concepts with well documented flow diagrams. It
also has a great description of the difference between JSP 
development models I and II.

[Article] The Java Performance Report: Part 3 
(Osvaldo Pinali Doederlein 09/02/2000)
A solid analysis of Java's performance relative to the different
JVM releases and compared to C++ code. The conclusion is if you really 
need speed, then you should use IBM's version 1.3 of JVM. The IBM 
versions of JVM engines may be found at IBM's web site.


[Article] SOAP  (Simeon Simeonov 9/2000)
This is today's last vocabulary exercise. SOAP (Simple Object 
Access Protocol) is a major XML-based initiative which in the 
future will impact JSP programmers. This article introduces 
SOAP and explains why we should pay attention to it.


================================================================
                     MAIN TOPIC by Casey Kochmer
================================================================
*****************  Death by Synchronization **********************


JSP is wonderful for the simplicity it brings to Java-based web site 
design. However, within this simplicity hides a potential killer. 
In short, JSP has features that make threading and synchronization 
deadly issues to the unwary.

Potential pitfalls include:

1) Large numbers of users using a small pool of objects.
2) Large numbers of users accessing a limited number of JVMs.
3) Declaration block methods and properties being treated as class 
   methods and properties.
4) Java objects, like vectors, having synchronization penalties.
5) Prebuilt components using internal synchronization blocks within 
   their code.
6) JSP pages frequently accessing database calls, causing a potential 
   bottleneck due to slow processing of a large SQL statement.
7) Programmers jumping into JSP without learning Java first.  
   Because JSP is relatively simple to use, many programmers don't 
   thoroughly acquaint themselves with Java and the issues of 
   synchronization.  This is especially dangerous for ASP programmers 
   where threading is not such a critical issue. 

These pitfalls mean trouble for everybody using a JSP site.  The 
trouble comes in three forms.

1) Mismanagement of application and class properties leading to
   corruption of the data stored in properties.
   
   Bill Venners' thread safety article addresses this 
   issue in more detail. When you read this thread safety article, 
   keep in mind that the JSP declaration block creates class 
   level properties.


2) Too many threads being used and causing memory allocation problems.
   (Remember --  high numbers of users but limited numbers of JVMs!)

   Tarak Modi's article  addresses this problem nicely.

3) Synchronization deadlock! A JSP application has seizures as threads 
   pile up behind each other while being processed in synchronized code 
   blocks.

   This article briefly reviews the synchronization deadlock issue.


SYNCHRONIZATION DEADLOCK EXAMPLE

A wonderful JSP system is built to display complicated data from a 
database. Everything works fine at first.  Then in production all of 
the sudden the browser times out every time a report is running. What's 
happening?  Well chances are this is due to death by synchronization. 
It's highly likely a synchronized code block exists where the SQL
statement is being processed. This synchronized block means the threads 
must run one at a time. If this SQL statement takes 2 minutes to run, 
and five requests are submitted, only one thread gets to run at a time
while the four other threads are waiting around doing nothing. To the 
user it looks like the browser has just locked up. It will be roughly
ten minutes in this example before the fifth thread gets done running, 
by which time the browser has probably timed out resulting in a server 
connection lost error. While this a simple example, it's a common 
mistake and one easy to replicate.


AVOIDING DEADLOCK

The following tips will help you sidestep the potential synchronization 
pitfalls.
 
1) Be aware the problem exists and design JSP modules with an eye 
   toward avoiding the it.

2) Be aware knowing about the problem does not make you immune to it. 
   As an example, consider what could happen when you use a third party 
   module which has synchronized blocks.  Just because other people are 
   using a pre-made module without problems doesn't mean your code will 
   interface nicely. Synchronization issues are unique to each 
   programming situation.  Your code's timing and a third party's module 
   timing may interfere with each other.

3) Stress test early. Stress testing can be a hard thing to do correctly 
   in a development environment.  Synchronization issues are something 
   that may easily remain hidden until your system goes into production 
   where load conditions are more extreme and variable. In other words, 
   when testing, try to simulate production conditions as closely as 
   possible.

4) Use an optimizing tool to watch the way your program runs. This method 
   should help you spot the bottlenecks.

5) Analyze your code for likely synchronization offenders while you're 
   building a program.  Watch for any process that takes a long time -- 
   this is where thread jams are most likely to occur.  Database access 
   is the most likely source of a bottleneck. Remote access to files, 
   applets or other outside sources are other potential problem areas. 

6) Be very careful with the isThreadSafe page directive.  It's easy to
   effectively synchronize an entire page (a large area of code) with 
   this command, increasing your potential for bottlenecks.  You face an 
   additional thread traffic jam when your concurrent requests exhaust 
   the servlet instance pool.  The server will be unable to handle 
   additional page requests until one of the currently processing pages 
   is finished.




ADDITIONAL REFERENCES

Designing for Thread Safety (Bill Venners)

Why Thread Pools are Important in Java (Tarak Modi)

================================================================
                           SUBSCRIPTION
================================================================
You may unsubscribe from or subscribe to this newsletter by going to:
http://www.jspinsider.com/jspbuzz/index.html

Browse all of the JSP Insider source-code.

Questions or comments? Contact support@jspinsider.com.