Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet as Application Controller  RSS feed

 
Jason Kwok
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a webapp using the MVC pattern. For the front-end I was thinking about creating an application-wide controller... in that this single controller would take all requests from browsers, and then send them off to other internal servlets for processing with their own respective models. After the results are found, they would be passed along with the uri for the appropriate view would be returned to the application servlet which would then return to the browser.

The entire front-end consists of dynamic content, provided through urls like www.mysite.com/Content?page=aboutus and posts to contact and search forms.

My question is if it is feasible to apply a Facade to the MVC pattern? And secondly, is this too much overhead just to support those functions? I want to ensure security as well and this seems better in that I can keep my internal servlets private.

I've had trouble passing parameters and attributes from servlet to servlet before, is this a bad practice?

Please advise!!
Jason
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a very common pattern to follow. it is in fact, how I code all my web apps. Please look over this article which may helpful.

Originally posted by Jason Kwok:
then send them off to other internal servlets for processing


Not another servlet, but rather classes following the Command pattern (see article).

The entire front-end consists of dynamic content, provided through urls like www.mysite.com/Content?page=aboutus


It's more common to use part of the servlet path to do the switching rather than request parameters.

My question is if it is feasible to apply a Facade to the MVC pattern?


It's not a Facade. Rather, the patterns employed are Front Controller and Command (and Data Transfer Object to carry info to the view).

And secondly, is this too much overhead just to support those functions?


Unless you code it badly, there is very little in the way of overhead.

I want to ensure security as well and this seems better in that I can keep my internal servlets private.


yes, this is why the Invoker is a poor idea.

I've had trouble passing parameters and attributes from servlet to servlet before


I have no idea why. There are no inherent problems.
 
Jason Kwok
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

It's clear I have much to learn, and I'm really intrigued with the Front Controller and Command pattern. Do you have sample code I code look at? While I understand what is going on, the front controller is a little unclear to me.

Thanks again,
Jason
[ March 26, 2007: Message edited by: Jason Kwok ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!