This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Servlet as Application Controller

 
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
 
Marshal
Posts: 67344
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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 ]
 
Self destruct mode activated. Instructions for deactivation encoded in this tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!