Copy Link
Add to Bookmark
Report

Java Coffee Break Newsletter Volume 2 Issue 11

         Java Coffee Break Newsletter Volume 2, Issue 11 
http://www.javacoffeebreak.com/
ISSN 1442-3790

=================================================================

In this issue

* Java in the news
* Free Java Publications? It's true!
* Book Review - Essential Java Style
* Book Review - The JFC Swing Tutorial
* Article : Sitting for the Sun Java Certification Exams
* Q&A : How do I read browser cookies from a servlet?
* Q&A : How do I make cookies expire after a set time period?

=================================================================

In the News

Here are a selection of recent news items that may be of
interest to Java developers.

/*/ Free Java Servlet Hosting
*** Repeat story, as the servlet host experienced ***
*** technical difficulty last month. ***

Finding an ISP that hosts servlets is a pain. They often
cost the earth, and impose strict conditions. One host
that I've come across offers free servlet and CGI hosting,
in return for popup banners. Popups aren't ideal, but for
servlet development and testing, it makes for a cheap
solution. For more information, visit
http://www.mycgiserver.com

/*/ Sun to offer new Java IDEs

Sun Microsystems has acquired the SynerJ and NetBeans
Integrated Development Environments (IDEs). Within the
next three months, Sun will be offering three levels of
development tools

* NetBeans Community Edition (normal development)
* NetBeans Internet Edition (CORBA, servlets, XML)
* Sun Forte for Java Enterprise Edition

More information is available from Sun Microsystems
http://java.sun.com/features/1999/10/tools.html

/*/ Kaffe 1.0.5 release claims threefold performance increase

Kaffe, a open-source JVM available for a variety of
platforms, has just been updated with partial JDK1.2
support, and a new JIT compiler that claims a threefold
increase in performance.

More details available from Kaffe at http://www.kaffe.org/


=================================================================

Free java publications? It's true!

Fatbrain, a large online bookstore aimed at the scientific and
computing communities, has recently announced that it will be
selling electronically published books and articles in Adobe
Acrobat and Microsoft Word format. To celebrate, they're offering
sample publications for free. I've selected some of the best Java
offerings, in one convenient location. In particular, I highly
recommend "Writing Robust Java Code", which offers good
strategies to improve your Java programming.

PS - I'll also be adding more selected titles there over the next
few months, including some commercial ones. There are a large
number of Java authors out there, and I'm hoping that there'll be
some great publications coming out over the next few months.

To see our list of recommendations, and download your FREE
titles, visit
http://www1.fatbrain.com/FindItNow/Services/home.cl?from=DRA482&s
tore=1

=================================================================

Book Review - Essential Java Style

Author : Jeff Langr
Publisher : Prentice Hall
ISBN : 0130850861
Experience: Intermediate - Expert


Most programming books on the market today cover a particular
language, programming technique, or field of computer science.
Aside from university texts, which deal with theory, most popular
titles deal with practical issues - the nitty-gritty details of
day to day software development. They're quick, fast paced, and
teach a particular topic, such as Java networking, or JDBC, or
Swing/AWT programming. They focus on how to achieve a task, on
short-term goals for programmers on the run.

A rarer, but no less important, type of book is one that focuses
improving the quality of software development. These type of
books usually become industry classics, if written well, and are
adopted by universities teaching software engineering classes.
But they aren't always relevant to "real-life" software
developers, who are often constrained by deadlines and just don't
have the time to produce perfectly polished code. The rarest type
of book of all is one that combines solid theory, with practical
applications. That's the type of book that "Essential Java Style"
attempts to be.

The principle underlying this book is that there are certain ways
of writing code that can improve the quality of software, and
make it easier to create, modify and debug. The book introduces
the reader to the principle of design patterns. Design patterns
are reusable templates for software design, that represent tried
and true solutions to common problems. Design pattern books have
been available for C++ and Smalltalk developers for years - but
there has been a shortage of good pattern books for Java.

"Essential Java Style" provides real-life code examples in Java,
as well as a good discussion of the reasons behind these patterns
and how they can aid the software development process.
The patterns are, for the most part, extremely useful and
relevant to practical Java programming - though a certain amount
of theoretical patterns that will cause an understanding amount
of frustration in practical development are also included. My
feeling is that some patterns would have been best left out,
while others are such a revolutionary idea that every Java
programmer should observe them. The challenge, for the reader, is
to choose which patterns to adopt, and which to refrain from
applying in practice.

While "Essential Java Style : Patterns for Implementation" is an
extremely good book for software developers, beginners to design
patterns and Java will find the book challenging. In addition,
the book suffers from very poor organization -- patterns are not
in order, and the reader will have to jump from one to another to
gain a thorough understanding. This not withstanding, almost
every developer will gain from applying these design patterns to
their applications -- not only in the short term, but in the
years to come as the application is refined and maintained. The
techniques described within "Essential Java Style" : Patterns for
Implementation" will most benefit the professional software
developer, who is involved in a team project and a
medium-to-large-scale software project. -- David Reilly

For more information about this title, or to order it, visit
http://www.davidreilly.com/goto.cgi?isbn=0130850861

=================================================================

Book Review - The JFC Swing Tutorial

Author : Kathy Walrath, 
Mary Campione
Publisher : Addison-Wesley
ISBN : 0201433214
Experience: Beginner-Intermediate


The JFC Swing Tutorial is a guide to designing applications that
use the Swing graphical components of the Java 2 Platform, and
also Swing for JDK1.1. The authors do a fine job of guiding the
reader through the basics concepts of Swing, and the new
graphical components. For developers with little AWT experience,
the new AWT event-delegation model is described in detail -
you'll learn how to write event handlers that respond to GUI
component actions.

I'm impressed by the clarity of this guide to Swing. Most Swing
books presume a high level of experience with constructing GUIs
in Java. However, I feel that the book could have gone much
further, and provided some moderate-to-large scale applications
as examples of what can be done with Swing. Many books devote a
chapter or two towards the end to a Do-It-Yourself project, and
offer step-by-step assistance. This is lacking from the book, and
would have really added to its appeal. I also found the layout of
the book distracting - it has been converted from a hypertext
document, and all the links are still underlined.  

The JFC Swing Tutorial is a good general guide to learning about
the Swing components. I feel that beginners will get more out of
this book though than experienced AWT programmers, who may wish
to consider other Swing titles. The book also includes a CD, with
copies of Swing, JDK1.1 and the Java 2 SDK.  -- David Reilly 

For more information about this title, or to order it, visit
http://www.davidreilly.com/goto.cgi?isbn=0201433214

=================================================================

Sitting for the Sun Java Certification Exams

The Sun Java Certification exams represent the best way
of demonstrating to an employer or client that you
possess competency in the Java language. The language
is relatively new, and many people has less than a few
years of experience in Java. However, with all of the
hype over Java, and the pressure to learn it, many
people pick up only the basics. With limited skill,
they claim to be Java gurus. If you want to demonstrate
your competency, consider studying for the Sun
Certification exams. -- David Reilly

Industry licensing and certification distinguish competent
professionals from amateur or trainee workers. Regardless of
the industry or field, these two things help to protect the
interests of employers, and the customers who rely on
sufficiently trained employees. The software industry is a little
different though from more traditional industries, in that there
exists no "programming license". Virtually anyone can claim to
program, even if they only learned it from a Dummies(tm) book
they finished last week. My pet peeve is people who claim to be
"software engineers", despite never having studied for a degree
in software engineering, or having picked up the additional
skills to justify the claim.

The software industry does, however, recognize certification.
Certification sets apart those willing to undergo extra training
and study to pass difficult and taxing exams from those who - for
whatever reason - choose not to. The reputation, for example, of
the Microsoft Certification exams is high. This is due in part to
the demanding nature of the exams, and the small number of people
who become certified.

Sun Microsystems, in an effort to provide a certification path
for the Java language, established the Sun Certification Exams.
Despite the existence of third party certification, passing the
Sun Certification Exam remains the preeminent way of verifying an
individual's proficiency with the Java language.


How do I become Sun Certified?

To achieve Sun Certification, you must pass one or more exams.
There are several exams on offer, catering for different types of
people: -

* Sun Certified Java Programmer for JDK1.02, JDK1.1 & Java 2
* Sun Certified Java Developer for JDK1.02, JDK1.1 & Java 2

In addition, a third type of exam (Sun Certified Java Architect)
has been added. The older JDK1.02 exam will also be phased out in
the future.

Sitting for the exams involves a small fee, which is
non-refundable for those who fail. For this reason, it is advised
that all candidates study before purchasing their exams.  


What do the exams involve?

Passing the Sun Certified Java Programmer exam involves answering
a series of multiple choice questions. Sound easy enough? There's
a little more to it though - you must select ALL the right
answers, without missing any or adding extra ones. Often the
difference between one answer and another is subtle, and it
requires a good understanding of the language and the base
Java APIs. Consider the following examples.


1. Which of the following is not a
public method or instance variable
of java.lang.String?

a) String.length
b) String.size
c) String.getLength()
d) String.length()

2. What keyword is used to specify a
class variable?

a) final
b) public
c) static
d) private

3. Which of the following are valid
comment(s)?

a) / This is a comment
b) /* This is a comment */
c) (* This is a comment *)
d) // This is a comment

4. Which of the following will not
produce a compile-time error?

a) public class MyString extends
java.lang.String
b) class MyClass implements
java.io.Serializable
c) class NetworkClient

Let's see how you did!

1) a & b & c
2) c
3) b & d
4) b & c

HINT - Q4 was a trick question. The String class is marked final,
so it cannot be subclassed. Passing the exam requires a good
knowledge of the Java API.


If you scored all four you're an ideal candidate for
certification right now. If not, you'll need to take a training
course, or read a Java certification guide.

For the full text of this article, including a comparison of
training guides, read it at the Java Coffee Break
http://www.javacoffeebreak.com/articles/certification/

=================================================================

Q&A: How do I read browser cookies from a servlet?

Reading cookies from a servlet is quite easy. You can gain access
to any cookies sent by the browser from the
javax.servlet.http.HttpServletRequest passed to the servlet's
doGet, doPost, etc methods. HttpServletResponse offers a method,
Cookies[] getCookies() which returns an array of Cookie objects.
However, if no cookies are available, this value may be null, so
be sure to check before accessing any array elements.

// Check for cookies
Cookie[] cookie_jar = request.getCookies();

// Check to see if any cookies exists
if (cookie_jar != null)
{
for (int i =0; i< cookies.length; i++)
{
Cookie aCookie = cookie_jar[i];
pout.println ("Name : " + aCookie.getName());
pout.println ("Value: " + aCookie.getValue());
}
}

=================================================================

Q&A: How do I make cookies expire after a set time period?

Depending on how you use the data stored in a cookie, it is often
a good idea to make the cookie expire. Since anyone using the
browser will have the cookie sent on their behalf, it may appear
to be a legitimate user when in actual fact it is not. This often
happens in places like Internet cafes, school or university
computing labs, or libraries.

If your cookie sends a user identifier that facilitates access to
sensitive data, or allows changes to be made (for example, a
web-based email service), then you should expire cookies after a
small time period. If the user keeps using your servlet, you
always have the option of resending the cookie with a longer
duration.

To specify an expiration time, you can use the setMaxTime(int)
method of javax.servlet.http.Cookie. It takes as a parameter the
number of seconds before the cookie will expire. For example, for
a five minute expiration, we would do the following :-

// Create a new cookie for userID from a fictitious
// method called getUserID
Cookie cookie = new Cookie ("userID", getUserID());

// Expire the cookie in five minutes (5 * 60)
cookie.setMaxTime( 300 );

When the cookie is sent back to the browser, using
HttpServletResponse.addCookie(Cookie), it will only be returned
by the browser until the expiration date occurs. If you'd prefer,
you can also specify a negative value for setMaxTime(int), and
the cookie will expire as soon as the browser exits. Note however
that not everyone will shutdown their browser, and it might be
available for minutes, hours even days. Finally, specifying a
value of zero will expire the cookie instantly.

=================================================================

Q&A: How do I gray out components, and prevent
users from using them?

Every AWT & Swing component inherits methods that will enable and
disable it, from java.awt.Component. The setEnabled(boolean)
method allows a component to be disabled, and later enabled.
Previously, AWT components could be enabled and disabled by
calling their enable() and disable() methods. However, these
methods have been deprecated, and should no longer been used.

// Disable button (b)
b.setEnabled ( false );
// Enable button (b)
b.setEnabled ( true );


=================================================================

The Java Coffee Break Newsletter is only sent out to email
subscribers who have requested it, and to readers of the
comp.lang.java.programmer and comp.lang.java.help
newsgroups.

If you'd like to receive our newsletter, and get the latest
Java news, tips and articles from our site, then get your FREE
subscription & back issues from

http://www.javacoffeebreak.com/newsletter/

If you are an email subscriber and no longer wish to receive
the JCB Newsletter, please unsubscribe by emailing
javacoffeebreak-unsubscribe@listbot.com

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT