Hi Bill!
I am using a front servlet pattern with Orion. I use Struts but I
suppose this approach should work in any framework.

1. The front servlet mapping in web.xml:
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>

So all the requests ending to .html are processed by the front-end
servlet.

2. All the valid URL's are mapped in an xml config file. The front
servlet initializes its state by reading this file in a startup. An
entry in this file looks like:
  <action    path="/faq"
             type="org.shiftctrl.general.interaction.EmptyAction">
    <forward name="success"              path="/faq.jsp"/>
  </action>

This means that the request http://myserver.com/faq.html is first
processed by front servlet. The servlet searches its configured mapping
and forwards the request. In this case it would forward the request to
faq.jsp.

I haven't had problems with this setup and I really like it for
following reasons:
1. It is easy pipeline actions. Just configure the mapping so that its
forward part points to another mapping.
2. You can hide the technology being used. Clients only see URLs which
are always ending .html (so .jsps are not exposed outside, their
function is only to provide the view part in MVC pattern)
3. It is possible to dynamically change the URL mapping by calling
appropriate methods in front servlet.

--
Joni
[EMAIL PROTECTED]

> Bill Winspur wrote:
> 
> In my web.xml I set up the servlet mapping, for a (front) servlet to
> handle all requests for the web app, to '/'. This works to the extent
> that all requests are passed to the servlet. BUT... if I do a forward
> to another resource from the servlet, the servlet's doGet() method is
> invoked recursively with no response generated until the jvm runs out
> of memory. The same thing happens with a url-pattern of '/*'. If the
> servlet itself generates html output, that works.  If I map my servlet
> to a specific resource, like /index.html, forwarding works fine, but
> the servlet cant handle all requests and 'http://myhost/myapp' returns
> 'no directory browsing'.
> 
> The url-pattern '/' seems like a valid directory specification (as per
> the servlet 2.2 spec, 'Servlet Mapping Techniques') and a front
> component, handling all requests is fundamental in the j2EE blueprints
> (http://java.sun.com/j2ee/blueprints/index.html, section 10.6), so my
> approach seems architecturally reasonable.
> 
> I've looked thru the archives and found two reports of the same
> problem. A proposed workaround from Magnus seems to recommend
> explicitly mapping every request your app generates (which would make
> the web.xml coding difficult to maintain in a large app) pendng the
> delivery of 'filters', perhaps in Servlet 2.3. I dont really
> understand what Magnus is suggesting:
> 
> PS: If you're bound to 2.2 or lower then you will not be able to use
> Filters, in that case you'd have to apply a more complex solution with
> duplicate resource roots and so on.
> 
> It looks like 'no front servlets on Orion' to me, but I hope I'm
> wrong.
> 
> I was not able to find any references to the problem on bugzilla, but
> I'm not very adept with its query interface.
> 
> My hunch is that Orion's request dispatcher is invoked in two contexts
> (from a client, and from a forward) and does not distinguish between
> them when it comes to selecting a resource to respond to the client.
> If the dispatcher ignored mapping in the forward context and just
> accepted the specified resource, the recursion problem would vanish
> and the front servlet would trap ALL client requests as per the
> blueprint architecture. Just a hunch, things are probably not that
> simple.
> 
> Does anyone know if this is a problem with other webservers ? My
> experience with Apache was all static pages.
> 
> My environment is NT4(sp6), Orion 1.4.8, IE 5.00, JDK 1.2.2.
> 
> Also, if somebody is actually using the front servlet pattern and
> univeral mapping on Orion, and could let me know how to set it up
> and/or get around the recursion I'd be a happy camper.
> 
> TIA,
> 
> Bill.

Reply via email to