• 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

Servlet as Application Controller

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
You can't expect to wield supreme executive power just because
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic