Tuesday, April 28, 2009

Mastering Spring MVC

JAVAWORLD'S ENTERPRISE JAVA ALERT
Solutions for Java developers
04/28/09

By Steven Haines

This brief history begins with Java's entry into Web application
development: the Servlet API
http://www.networkworld.com/nljavaworldsente183218 , introduced
in 1997. Before then, developing dynamic Web applications with
disparate APIs and programming models proved to be challenging.
(I'll resist the urge to recap the old days of CGI
http://www.javaworld.com/jw-01-1997/jw-01-cgiscripts.html , the
futile battle between Netscape Server plug-ins and ISAPI
plug-ins, and all the homegrown APIs.) The Servlet API provided
a standard on which vendors could build Web containers and
developers could implement a simple programming model for
constructing Web pages.

With servlets, dynamically constructing HTML documents became
easy. But because the documents were constructed inside Java
source code, maintenance was challenging. For example, changing
a font or moving a piece of content within a page required you
to update the HTML inside the servlet code and then recompile
and redeploy it to the container.

Sun resolved this issue in 1999 by introducing JavaServer Pages
http://www.networkworld.com/nljavaworldsente193842 (JSP).
Rather than implementing presentation code inside servlets, JSPs
lets you build HTML-like documents that interweave snippets of
Java code to support dynamic content. At runtime, JSPs are
translated to servlet source code, compiled, and then deployed
to a Web container dynamically. If you change any part of the
JSP, the container detects the change, recompiles the page, and
redeploys it. This architecture was calledpage-drivenor Model 1.

In page-driven applications, each page not only contains the
business logic required to generate the dynamic content, but
also the control logic to determine application flow. Control
logic became difficult to maintain because there was no central
location or design paradigm to help you understand how a user
passed from one page to the next. And as business requirements
evolved to include features like authentication and
authorization, page code became convoluted with additional logic
that usually had to be duplicated across pages, even if it was
irrelevant to the page being constructed. On a site with 1,000
pages, all with authorization mechanisms, who wants to update
all 1,000 pages when those authorization mechanisms change?

The solution was to separate programmatic responsibilities into
the technologies best suited for them. Servlets are great for
writing Java code, acting as a central point for managing
application flow and invoking business methods, but horrible at
presentation; JSPs are great at presentation but are a horrible
place to embed all of your business logic. Thus was born the
Model 2 architecture
http://www.networkworld.com/nljavaworldsente193843 , which
adheres to the MVC Smalltalk design pattern:

1. The model represents your data or the objects with which your
application is interacting.

2. The view is a visualization of your model.

3. The controller manages application flow and makes calls into
business objects.

Read more: Mastering Spring MVC - A hands-on tutorial
http://www.networkworld.com/nljavaworldsente193844

Related:

1. Spring Web Flow 2: A boon to JSF developers
http://www.networkworld.com/nljavaworldsente169325

2. Understanding JavaServer Pages Model 2 architecture
http://www.networkworld.com/nljavaworldsente193843

3. Discussion: Is Spring MVC worth attention in 2009?
http://www.javaworld.com/community/?q=node/2849

New! Java Tip: Extending declarative caching services for Spring
http://www.javaworld.com/community/node/2821

Spring Modules offer an easy way to add and tune caching
functionality without touching an application's code, but the
approach often falls short when scaled in real-world scenarios.
This tip explains real-world problems faced when using Spring
Modules for declarative caching and extends the existing
declarative model to address them.

Related:

1. Peruse the Java Tips Archive - 143 tips in all!
http://www.javaworld.com/columns/jw-tips-index.html

2. Subscribe to the Java Tips Blog feed
http://www.javaworld.com/community/blog/21645/feed

3. Got a tip? Submit it here mailto:jwedit@javaworld.com

New! Podcast: Make way for Jetty: Coming of age at 12
http://www.networkworld.com/nljavaworldsente193845

Jetty is a lightweight Java and Web application server that has
been making waves since turning 12 in the first months of 2009.
In this talk with Andrew Glover, Jetty engineers Greg Wilkins
and Jan Bartel discuss core aspects of Jetty that have made it a
popular choice for Web application deployment in Web 2.0
environments. Topics include Jetty's early adoption of
Comet-style "server push" interactions, its use in Android and
other mobile application environments, its lightweight,
embeddable component model, and its recent adoption as an
Eclipse Foundation project. Webtide CEO Adam Lieber joins in to
discuss the open source business strategy behind Jetty and other
Webtide initiatives.

Listen up: Greg Wilkins and Jan Bartel: Why Jetty is succeeding
now http://www.networkworld.com/nljavaworldsente193845

When the job changes but the programmer doesn't, Part 2: Saving
Frank's job http://www.javaworld.com/community/node/2796

By Esther Schindler

Last week, I described the plight of a maintenance programmer
whose company was moving to a new language and development
platform. Although Frank has worked for the medium-sized company
for some years, he's just not being productive. I promised the
rest of the story this week ....

Deadlock anti-patterns #3: Incremental locking
http://www.javaworld.com/community/node/2789

By Obi Ezechukwu

Tthe incremental locking anti-pattern is simple, well-known, and
well documented -- and is unfortunately still a frequent
mistake. Chances are that most developers who have had the
misfortune of debugging deadlocking code would have come across
this pattern at some point in their career ...You've hit the tip of the iceberg: Read more in JW Blogs
http://www.javaworld.com/community/

_______________________________________________________________
This newsletter is sponsored by Sun Microsystems
Java + You = Registration

Meet the most amazing experts at the 2009 JavaOne Conference.
June 2-5 in San Francisco, CA. Learn more.
http://adserver.fattail.com/redir/redirect.asp?CID=298628
_______________________________________________________________

Metzler: 2009 Handbook of Application Delivery.
Successful IT organizations must know how to make the right application delivery decisions in these tough economic times. This handbook authored by WAN expert Jim Metzler will help guide you.
http://www.nww.com/rpgx.jsp?c=XU1PTA7013Z4343
_______________________________________________________________

This Newsletter Subscription Compliments of: Linuxworld.com http://www.linuxworld.com

ALSO FEATURED ON JAVAWORLD

Java Tip: Extending declarative caching services for Spring
http://www.javaworld.com/community/node/2821
Spring Modules offer an easy way to add and tune caching
functionality without touching an application's code, but the
approach often falls short when scaled in real-world scenarios.
This tip explains real-world problems faced when using Spring
Modules for declarative caching and extends the existing
declarative model to address them.

Lean service architectures with Java EE 6
http://www.networkworld.com/nljavaworldsente191680
Thanks to Java EE 6's simplified development model, a few
interfaces and annotated classes are all you need to implement
the facade, the service, and the domain structure that
constitute a lean service-oriented architecture. Surprised? Read
on.

Writing good unit tests, Part 2: Follow your nose
http://www.networkworld.com/nljavaworldsente191096
Klaus Berg continues his investigation of the tools and best
practices that facilitate programming with GUTs. Get tips for
writing cleaner, more efficient assertions, handling checked and
unchecked exceptions, and knowing when and how to refactor your
test code. Examples are based on JUnit 3 and 4, TestNG, and
Hamcrest.

Jump into JavaFX, Part 4: The advanced APIs
http://www.networkworld.com/nljavaworldsente190628
Jeff Friesen completes his comprehensive tour of the JavaFX APIs
with a look at how JavaFX handles media, GUIs, and special
effects. You'll also try your hand at building and deploying a
stock-ticker application to Google Chrome.

REST for Java developers, Part 4: The future is RESTful
http://www.networkworld.com/nljavaworldsente190066
Find out why REST interfaces are foundational for emerging
architectures such as the Semantic Web. Brian Sletten takes a
big-picture view of REST, now and in the future, in this final
article in his series.

Understanding actor concurrency, Part 2: Actors on the JVM
http://www.networkworld.com/nljavaworldsente188943
Erlang isn't the only language for implementing actor
concurrency. Find out how actors work and see them implemented
in Scala's standard library, Groovy's GParallelizer, and the
Java libraries Kilim, ActorFoundry, Actors Guild, and Jetlang.

_______________________________________________________________
This newsletter is sponsored by Sun Microsystems
Java + You = Registration

Meet the most amazing experts at the 2009 JavaOne Conference.
June 2-5 in San Francisco, CA. Learn more.
http://adserver.fattail.com/redir/redirect.asp?CID=298628
_______________________________________________________________

UPCOMING ON JAVAWORLD

-Know your Oracle application server
-Cloud-ready, multicore-friendly code, Part 2
-Tapestry 5: Day one
-Clojure: Challenge your Java expectations
-The Ajax developer's toolkit: An overview
-Open source Java projects: JCC

Podcasts:

-Howard Lewis Ship: What's new in Tapestry 5
-Grant Ingersol: Lucene and Solr

JavaWorld's Daily Brew - Starting conversations in the Java
developer community
http://www.javaworld.com/community
_______________________________________________________________

BONUS FEATURE


Metzler: 2009 Handbook of Application Delivery. Successful IT
organizations must know how to make the right application delivery
decisions in these tough economic times. This handbook authored by
WAN expert Jim Metzler will help guide you.
http://www.nww.com/rpgx.jsp?c=XU1PTAZ4343


_______________________________________________________________

May we send you a free print subscription to Network World?
You've got the technology snapshot of your choice delivered at
your fingertips each day. Now, extend your knowledge by
receiving 50 FREE issues to our print publication. Apply today
at http://www.subscribenw.com/nl2

International subscribers click here:
http://nww1.com/go/circ_promo.html
_______________________________________________________________

SUBSCRIPTION SERVICES

To make newsletter subscription changes or cancellation, please
go to:
http://www.subscribenw.com/nl/login.jsp

To change your e-mail address, go to:
http://www.subscribenw.com/nl/eclogin.jsp

Subscription questions? Contact Customer Service by replying to
this message.

This message was sent to: athenssuthakar.javaupdates@blogger.com
Please use this address when modifying your subscription.
_______________________________________________________________

For advertising information, write Susan Cardoza, Associate
Publisher Online, at: mailto:sponsorships@nwfusion.com
_______________________________________________________________

JavaWorld is a trademark or registered trademark of Sun
Microsystems, Inc. in the United States and other countries, and
is used under license by International Data Group, Inc. All
other product names and trademarks used are the trademarks of
their respective owners.

Copyright 2009 JavaWorld.
http://www.javaworld.com