Tuesday, August 25, 2009

PSSServlet- mimics component oriented frameworks

PSSServlet (Mimicing Component oriented frameworks)

There are many component oriented java web frameworks, as well as request oriented frameworks as well which existed from starting of servlets.

Component oriented frameworks try to mimic desktop like environment by trying to detach entire User objects from complexities of HTTPServletRequest plumbing. This is not yet a theoritically proven concept as there are still limitations to it.

Component Oriented Pipeline

Request Based Pipeline

In request based frameworks like SpringMVC(powerful), struts the User objects have complete access to HTTP Servlet request objects. While the fundamental complication that component based frameworks enter into is – “they detach request from end user objects”. This concept has too much impact. Once user has no access to fine grained control over response generated, too much magic is done by component based framework. This include generation of unique ids for each detached user object properties inside the HTML so that they can be uniquely tracked within the server, when next request hits server. This will create big problem if similar userId is generated across pages and some javascript submits requests across pages. Javascripting becomes a nightmare. There is a need to synchronize javascript events with server component events(?)..

Arbitary change of DOM model and its handling in server should be carefully done in component based frameworks. In an HTML, it may not be just that form submissions/javascript interactions happen only with one Page. All possible combinations of dynamic form creation/subission to multiple pages dynamically have to be considered.

It often ends up that the end user has to know internals of these component based frameworks like tapestry, wicket, JSF very well before using any of these frameworks. For that matter JSF is simplistic, and easier to learn. You just normally create a new FacesContext object and loop through various JSF phases on top of FacesContext which you can access from anywhere.

Request based frameworks:

HTTPServletRequest based objects are fully accessible in request based frameworks. This allow full finegrained control of logic that can happen when requests come and go back. Struts- mvc-frontcontroller pattern allowed good seperation of logic. Spring MVC is even more powerful allowing multiple controllers and many other features. Still the amount of services that these frameworks provides is fixed.

Question comes: why can't users extend to add/redistribute more services which these servlets can use. Possibility of expansion of request based framework is very large as in PSSServlet.

This is just a concept trying to mimic tapestry/wicket like HTML templating mechanism with just 3 java files. Its like JSP's <%= %> as well as “jsp:include” . Just the fact that JSP cannot be extended easily, make this sort of PSSServlet needed. Writing new frameworks similar to struts, involves more coding by extending upon JSP codebase.

Why not just stick to servlets alone which is bare minimum and extend on that by providing a cloud of services which user can invoke in a pipelined manner to minimize coding.


It has 4 java files as of release (1 days coding effort). Actually just 2 java files: MarkupWriter and PSSServlet. PSSComponent is copy-paste of PSSServlet, and PSSSession is having just one hashtable. PSSServlet has dependency on 2 external jars:ognl and javassist for expression evaluation.

Features(as of now it follows SingleThreadedModel):

  1. for each Servlet, it auto renders corresponding HTML template similar to JSP.

  2. Takes property markup and renders property populated in servlet at appropriate time/phase as what user decides(no one phase like JSP)

  3. the markup is maintained in chunks(concept from book- tapestry in action), and can be dynamically overwritten in appropriate phase

  4. owcid/pwcid. owcid- refers to object web-component id(a sub template/seperate web component). pwcid is just a property id within servlet. Usage- ${owcid:<component-name>:<argument-param>} . ${pwcid:<property-ognl-expression>}

  5. rendering of subcomponents order can be fine controlled and even the order. Populating from session should happen at what phase is also controlled

  6. Full access to HttpServletRequest, HttpServletResponse object throughout.

Final Say:

So many frameworks might have come about because of improper design of JSP(just trying to mimic ASP). Time to improve on JSP itself, and provide more concrete servlet based frameworks which has huge flexibility and efficiency.


  1. Sounds interesting,

    Two things, one or two samples would help us understand better. Also, single threaded? does it mean serialization of requests? if it is, how would you expect this to impact performance.

    Best regards, Carlos

  2. There is PSSServlet-v0.5.0.0.war that can be downloaded from sourceforge.net/projects/pssservlet/files/ which has 2 servlet examples (one with a component)

  3. I use a (mainly self-written) component based framework for 8 years now - without any nightmare-problems. The most "official" framework are not abstract enough. It still shines through that you do web programming - and they are centered to that. A real good framework does not differ between gui-systems. They provide an abstract programming model to mvc - no matter if you choose swing, html/js or others. And believe me: It works! No pain!

  4. Hi Friend,
    Congratulations for this nice looking blog. In this post everything about Web Development. I am also interested in latest news, sometimes i posted on Customized application development



About Me