File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Routing servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Routing servlet" Watch "Routing servlet" New topic
Author

Routing servlet

Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
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

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Jul 31, 2003
Posts: 294
Thanks david!

That�s exactly what I looked-for
Dani Mazzuca
Ranch Hand

Joined: May 21, 2003
Posts: 70
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

Joined: Jul 31, 2003
Posts: 294
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

Joined: Jul 31, 2003
Posts: 294
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

Joined: May 21, 2003
Posts: 70
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

Joined: Jul 31, 2003
Posts: 294
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

Joined: Aug 17, 2001
Posts: 399
Hi Sharon
Its not always necessary to use STRUTS to implement MVC pattern.
hth
MB


Malhar Barai
SOA & Java Book
Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
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

Joined: Jan 10, 2002
Posts: 60782
    
  65

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
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 ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Routing servlet
 
Similar Threads
JMF-RTP audio. please help.
Need help with DD
Creating a Server
How to read data from the routers?????
Need help in using apache camel routing