aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFS&JSP - patterns? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFS&JSP - patterns?" Watch "HFS&JSP - patterns?" New topic
Author

HFS&JSP - patterns?

Richard Quist
Ranch Hand

Joined: Feb 18, 2004
Posts: 96
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


Rich
SCJP 1.4
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8815
    
    5
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 ]

Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Richard Quist
Ranch Hand

Joined: Feb 18, 2004
Posts: 96
Excellent!

Thank you.
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
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


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Bryan Basham
author
Ranch Hand

Joined: Apr 30, 2001
Posts: 199
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
Colin Fletcher
Ranch Hand

Joined: Sep 10, 2004
Posts: 200
Here is the link to the Spec from Sun.


SCJP 1.4 SCWCD 1.4
Roger Yates
Ranch Hand

Joined: Aug 31, 2004
Posts: 118
Nice diagram, duly bookmarked


Cheers,<br />Roger<br />SCJP 1.2, 1.4, SCBCD 1.3, SCWCD 1.4
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
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
Ranch Hand

Joined: Apr 30, 2001
Posts: 199
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

Joined: Nov 07, 2003
Posts: 4982
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: HFS&JSP - patterns?