You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Aiken, David" <Da...@bmc.com> on 2000/12/01 21:26:40 UTC

RE: MVC problem

hi vik..

We would be interested in your example.. it seems that the conventional
controller servlet is a bit ambitious at this stage :>(.

david

-----Original Message-----
From: Vik P. Solem [mailto:vsolem@viktech.com]
Sent: Thursday, November 30, 2000 4:21 PM
To: tomcat-user@jakarta.apache.org
Subject: Re: MVC problem


OK, this works (tested in Tomcat 3.1).

Extend HttpServlet and implement HttpJspPage. (The easy way is to copy
HttpJspBase.java and then edit the service() method.)

Then have your JSP's (or your servlets I think, but I haven't tested
that yet) extend the new class that you just created.

In the service method you can do any pre processing that you like before
ever getting to the JSP page itself.  This allows you to write a bit of
code once and have it run in front of every page that you want.

I have a dumb example of this for Tomcat 3.1.  For the curious, please
send me email directly, as I'm a bit uncomfortable at the current length
of this thread.

-Vik

"Vik P. Solem" wrote:
>
> Hello David.
>
> I don't know if this will help you, but when we needed to perform some
> basic functionality prior to each page request we created a super-class
> for our servlets (actually it was jhtml, not JSP, but it was a while
> ago).
>
> This super class was a servlet that implemented the method
> service(req,resp), and in that method we did some important global
> things.  We tracked page level security, guaranteed a single thread per
> session (by synchronizing on the session object), and then after/within
> that logic we called super.service(req,resp) which then went on to run
> the appropriate page for us.  (This requires that your JSPs (or servlets
> if you write the controller separately as I'd suggest) extend this
> intermediary class which would in turn extend HttpJspBase.
>
> I'm not sure if I've explained it very well.  I'd be happy to write a
> better description if you'd like one.  Please feel free to email me
> directly at vsolem@viktech.com.
>
> Assuming that I've described it well enough that it's recognizable, has
> anyone else out there used this approach?
>
> -Vik
>
> "Aiken, David" wrote:
> >
> > > hi all..
> > >
> > > We're hitting a problem with the MVC approach in tomcat.
> ...
> --
> Vik P. Solem    vsolem@viktech.com    781-344-1133
> VikTech Systems Inc.   Built right, now.
> http://www.viktech.com

--
Vik P. Solem    vsolem@viktech.com    781-344-1133
VikTech Systems Inc.   Built right, now.
http://www.viktech.com