• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFS&JSP - patterns?

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The blurb about the book on Amazon mentions "Learn to ... and even use some server-side design patterns."

What patterns are discussed, and how much detail?

Thanks
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Richard,

The last two chapters (and about half a chapter in the beginning of the book), are devoted to patterns.

Near the begining of the book we do an intro to web-MVC. The penultimate chapter is all about filters. This chapter does double duty, giving you an insight into the Intercepting Filter questions you might experience on the exam, and also giving you a good foundation in how this pattern is applied to the implementation in the Servlet spec.

The last chapter is all about J2EE patterns, Struts, and MVC. The J2EE patterns we cover are: Business Delegate, Service Locator, Transfer Object, and Front Controller.

So the exam objectives mention 6 patterns. MVC isn't considered by some to be an official, card-carrying, J2EE pattern, but it's obviously important. The other five ARE J2EE patterns, although given the Servlets application of filters it would be rare to apply your own hand-rolled intercepting filter.

We provide a quick overview to Struts - remember it's NOT on the exam, but we thought it important enough to cover anyway (and by "cover" I mean "get your feet wet").

- Bert

p.s. We get into a good level of detail on coding filters (with 2 code examples, a request filter and a response filter), and we provide a complete (albiet tiny), Struts application, in code. The other patterns are described at a conceptual level, but I'd say it's a "detailed, conceptual" conversation
[ October 19, 2004: Message edited by: Bert Bates ]
 
Richard Quist
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excellent!

Thank you.
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bert,

By talking about the pattern issue, I sometimes feel confused about MVC and FrontController, as seems both of them define a controller to receive the request, and then dispatch to the required services, as well as the presentation layer.

Could you explain a bit on the major difference? Some books said FrontController is the control of the workflow, while MVC does not, is that really true?

Nick
 
author
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nick,

I'll tackle this one...

Originally posted by Nicholas Cheung:
By talking about the pattern issue, I sometimes feel confused about MVC and FrontController, as seems both of them define a controller to receive the request, and then dispatch to the required services, as well as the presentation layer.

Could you explain a bit on the major difference? Some books said FrontController is the control of the workflow, while MVC does not, is that really true?



First of all, MVC does not imply only one controller; in fact, quite the opposite. There is usually one controller object for each action that your user interface must process. In a webapp, this means that you need one application controller (either a servlet in a non-Struts webapp or a Struts Action subclass) for each *type* of HTTP request.

A FrontController (FC) has nothing to do with MVC and this pattern can be applied to a non-MVC webapp as well as an MVC webapp. An FC is what is known as an infrastructure controller.

Also check out my reply in: Can we have more than one controller in MVC pattern?

-Bryan
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the link to the Spec from Sun.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice diagram, duly bookmarked
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bryan,

That is to say, if I use FC, there should be only 1 Servlet that controls the workflow, while this FC knows everything, and be able to deligate the requests to different *sub* controller to continue the process?

Nick
 
Bryan Basham
author
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nicholas Cheung:
That is to say, if I use FC, there should be only 1 Servlet that controls the workflow, while this FC knows everything, and be able to deligate the requests to different *sub* controller to continue the process?



There are many ways to implement the FC pattern. You can use a servlet (as is done in Struts with the ActionServlet) or you can use a filter or some other bizarre mechanism you might concoct. However, the servlet-FC implementation is the easiest to understand and so it is the most common.

The hard part of the FC pattern relates to the second part of you question: "while the FC knows everything..." In reality, you do not want the FC to know anything about the application logic/controllers. So, what most FC impls do is give you some configuration file (such as the struts-config.xml file in Struts) that allows the FC impl to be completely generic. The "sub controllers" (or more accurately, "application controllers") are declared in the configuration file that the FC uses to dispatch each request to the appropriate application controller.

Make sense?

-Bryan
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, we may need to define our own configuration for FC, including its own details, as well as the subelements for some other controllers, init them when needed by passing in the subelements configuration?

Nick
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic