• 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 a Facade for Webapp

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm writing a servlet which is to act as a facade for the web application.
It needs to check some details and the forward to the requested uri.

I have declared the web.xml entry as

<servlet><description>This is the main Facade for the webapp</description>
<display-name>Facade</display-name>
<servlet-name>Facade</servlet-name>
<servlet-class>com.myapp.web.servlets.Facade</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Facade</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

Within the servlet, I'm trying to forward like this

ServletContext ctx = getServletConfig().getServletContext();
ctx.getRequestDispatcher("/jsp/signin.jsp").forward(request, response);

Now the problem is that as soon as i forward, the request comes back to the facade again. This results in a recursive looping.

Any insights how I can break that.
I'm using Tomcat 6 & I can't have urls like *.do. No extensions.
So its like I need every incoming request to come to my facade but not the ones that the facade itself forwards.
I'm kind of stuck here [banghead]
Thanks
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'm using Tomcat 6 & I can't have urls like *.do. No extensions.



Typically, when you want to avoid extensions but want a front controller, you create a directory like structure for your URL pattern.

<url-pattern>/command/*</url-pattern>

This allows you to grab all commands but not force things like image requests, JS, CSS, etc. to be forced through your controller servlet.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Patterns of Enterprise Application Architecture: Front Controller
Core J2EE Patterns 2e: Front Controller
J2EE Patterns: Front Controller
Blueprints: Front Controller
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic