Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Routing servlet

 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to make servlet that will act as Routing servlet,
all user requests will pass through this servlet ,
and he will decide whether to process the request or not .
(I am aware of the disadvantage's of such servlet )
any ideas ??
thanks .
Sharon .
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a common pattern commonly called the Front Controller, and acts as a part of the Model-View-Controller or MVC pattern.
A search in the JSP and Servlet forums at the 'Ranch will give you a wealth of information on these!
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks david!

That�s exactly what I looked-for
 
Dani Mazzuca
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

you can also find more information about FrontController and MVC in the Sun site:
http://java.sun.com/blueprints/patterns/catalog.html
BTW, if you are only redirecting the request, you should consider to implement your code in a filter.
Dani
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW, if you are only redirecting the request, you should consider to implement your code in a filter.

Thank you Dani for this grate link!
I am building an application to be installed on a j2ee web site and I am trying to make its influence on the website � minimal.
I cannot implement filters because they impose me to change the web site original servlets code,
Sharon
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BUS(between us... ) nothing on the articles I found describes the server configuration e.g. (tomcat, RI, Jboss...)
Is the configuration similar on all servers?
I found the tomcat vary easy to configure ( minor change on the web.xml file)
Thanks,
Sharon .
 
Dani Mazzuca
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I don't know if I understand very well, however, web.xml configuration is standard in all containers (except the old ones). Tomcat is only a webserver, not a J2ee server. Anyway, each container (enterprise or web), has its own way to configure extras parameters, like directory os the log file, etc. In general all containers have a web interface application to configure its specific parameters (although these configurarions are actually done in xml files behind the scens).
Dani
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I�m starting to understand ...
I must implement the MVC architecture using the STRUTS from apache in order to be able to make my Front Controller work.
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sharon
Its not always necessary to use STRUTS to implement MVC pattern.
hth
MB
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Malhar
ok , I see . :roll:
I don't have to use STRUTS ,
but how do I know who called my Front Controller servlet , and what address is he requesting ???
I read the sun tutorial, and they use classes I don't recognize like :
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A common way is to use the rest of the URL (after the mapping) to specify what to do.
For example, im my front controller implementation, the URL mapping for my Front Controller servlet is '/action'. So a URL such as:

invokes my Front Controller servlet, which then looks at the URL and determines that I want to perform the 'Whatever' action. (Just how you invoke an action from that point on is up to you --- I have a config file that maps these action names to classes that implement an Action interface... Struts-like, but different).
hth,
bear
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Bear ,
you said : "which then looks at the URL"
how exactly ??
Another thing , your Front Controller servlet is answering '/action'
my Front Controller answer all requests and that's why I considered STRUTS ,
but when I configure the web.xml instead I get recursive calls to my servlet ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic