You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Kaur, Jasdeep Guglani" <ja...@gmail.com> on 2008/01/23 16:08:03 UTC

Re: Initializing multiple VelocityServlets

Hi Thanks for responding...

If I have to use Velocity Servlet...can this problem be rectified....


On 1/23/08, Will Glass-Husain <wg...@forio.com> wrote:
>
> Hi,
>
> Have you looked at the Velocity Tools subproject?  Look at the
> VelocityViewServlet.  It's a much better servlet and is actively
> maintained.
>
> Let's take any other discussion to the user@velocity.apache.org
> mailing list please.
>
> WILL
>
> On 1/23/08, Kaur, Jasdeep Guglani <ja...@gmail.com> wrote:
> > Hi
> >
> > I wish to use the code written by. Attcahed is the file you wrote. It
> has
> > alternate version of the Velocity servlet to load multiple instances.
> >
> > I extend this class and want multiple instances of the subclass too. Is
> it
> > possible? or how else can I proceed to wards it...
> >
> >
> >
> > I can quote my problem in following way:
> >
> > There is a servlet (VMServlet) that handles all our requests. It has a
> > member variable viz. "user" that stores the username etc. As we are
> using
> > singleton model; only one copy of the VMServlet class gets created.
> >
> >
> >
> > So when multiple users log into the application, and there is one
> instance
> > of the VMServlet which is handling the requests, we see wrong user name
> in
> > the application. This problem appears when more than one instance of the
> > application are  busy processing simulataneously.
> >
> >  The VM Servlet class extends VelocityServlet.
> >
> >
> >
> > In VelocityServlet class I made some change to drop the singleton model
> > being followed earliar.
> >
> > The change is
> >
> > protected void initVelocity(ServletConfig config)
> >
> >         throws ServletException
> >
> >     {
> >
> >         try
> >
> >         {
> >
> >             Properties props = loadConfiguration(config);
> >
> >             //Velocity.init(props); This line was commented
> >
> >
> >
> >             /* Code inserted */
> >
> > ve = new VelocityEngine();
> >
> >                   System.out.println("\n\n\n*************In Velocity
> Servlet
> > Modified****************");
> >
> >             ve.init(props);
> >
> >         }
> >
> >         catch(Exception e)
> >
> >         {
> >
> >             throw new ServletException("Error initializing Velocity: " +
> e,
> > e);
> >
> >         }
> >
> >     }
> >
> > But this has not solved the problem.
> >
> >
> >
> > Do you have any idea how to go about it? your alternate velocity servlet
> has
> > not solved my problem.
> >
> > Please help...n thanks!
> >
> >
> >
>
>
> --
> Forio Business Simulations
>
> Will Glass-Husain
> 415 440-7500x89
> wglass@forio.com
> www.forio.com
>

Re: Initializing multiple VelocityServlets

Posted by Thomas Vandahl <th...@tewisoft.de>.
Kaur, Jasdeep Guglani wrote:
> even implementing the VelocityViewServlet has not solved my problem.
> 
> My class VMServlet which handles all vm requests is being extended from
> VelocityViewServlet. still only one instance of the VM Servlet is created in
> the memory to handle the requests even if they come from different session
> ids...

Servlets are singletons by design. It's their life cycle. You should 
store request-dependent data in the request and session-dependent data 
in the session (see HttpSession.setAttribute()). Velocity is not 
involved here.

Bye, Thomas.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Initializing multiple VelocityServlets

Posted by "Kaur, Jasdeep Guglani" <ja...@gmail.com>.
even implementing the VelocityViewServlet has not solved my problem.

My class VMServlet which handles all vm requests is being extended from
VelocityViewServlet. still only one instance of the VM Servlet is created in
the memory to handle the requests even if they come from different session
ids...


Please help....


On 1/23/08, Kaur, Jasdeep Guglani <ja...@gmail.com> wrote:
>
> Please reply....what steps are needed tp move from VelocityServlet to
> VelocityViewServlet.
>
> I downloaded the jar velocity-tools-view-1.4.jar. and extended my
> VMServlet class from velocityViewServlet. what other changes are required.
>
> Please guide its urgent.
>
>
>  On 1/23/08, Kaur, Jasdeep Guglani <ja...@gmail.com> wrote:
> >
> > Hi Thanks for responding...
> >
> > If I have to use Velocity Servlet...can this problem be rectified....
> >
> >
> >  On 1/23/08, Will Glass-Husain <wglass@forio.com > wrote:
> > >
> > > Hi,
> > >
> > > Have you looked at the Velocity Tools subproject?  Look at the
> > > VelocityViewServlet.  It's a much better servlet and is actively
> > > maintained.
> > >
> > > Let's take any other discussion to the user@velocity.apache.org
> > > mailing list please.
> > >
> > > WILL
> > >
> > > On 1/23/08, Kaur, Jasdeep Guglani < jasdeepkg@gmail.com> wrote:
> > > > Hi
> > > >
> > > > I wish to use the code written by. Attcahed is the file you wrote.
> > > It has
> > > > alternate version of the Velocity servlet to load multiple
> > > instances.
> > > >
> > > > I extend this class and want multiple instances of the subclass too.
> > > Is it
> > > > possible? or how else can I proceed to wards it...
> > > >
> > > >
> > > >
> > > > I can quote my problem in following way:
> > > >
> > > > There is a servlet (VMServlet) that handles all our requests. It has
> > > a
> > > > member variable viz. "user" that stores the username etc. As we are
> > > using
> > > > singleton model; only one copy of the VMServlet class gets created.
> > > >
> > > >
> > > >
> > > > So when multiple users log into the application, and there is one
> > > instance
> > > > of the VMServlet which is handling the requests, we see wrong user
> > > name in
> > > > the application. This problem appears when more than one instance of
> > > the
> > > > application are  busy processing simulataneously.
> > > >
> > > >  The VM Servlet class extends VelocityServlet.
> > > >
> > > >
> > > >
> > > > In VelocityServlet class I made some change to drop the singleton
> > > model
> > > > being followed earliar.
> > > >
> > > > The change is
> > > >
> > > > protected void initVelocity(ServletConfig config)
> > > >
> > > >         throws ServletException
> > > >
> > > >     {
> > > >
> > > >         try
> > > >
> > > >         {
> > > >
> > > >             Properties props = loadConfiguration(config);
> > > >
> > > >             //Velocity.init(props); This line was commented
> > > >
> > > >
> > > >
> > > >             /* Code inserted */
> > > >
> > > > ve = new VelocityEngine();
> > > >
> > > >                   System.out.println ("\n\n\n*************In
> > > Velocity Servlet
> > > > Modified****************");
> > > >
> > > >             ve.init(props);
> > > >
> > > >         }
> > > >
> > > >         catch(Exception e)
> > > >
> > > >         {
> > > >
> > > >             throw new ServletException("Error initializing Velocity:
> > > " + e,
> > > > e);
> > > >
> > > >         }
> > > >
> > > >     }
> > > >
> > > > But this has not solved the problem.
> > > >
> > > >
> > > >
> > > > Do you have any idea how to go about it? your alternate velocity
> > > servlet has
> > > > not solved my problem.
> > > >
> > > > Please help...n thanks!
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Forio Business Simulations
> > >
> > > Will Glass-Husain
> > > 415 440-7500x89
> > > wglass@forio.com
> > > www.forio.com
> > >
> >
> >
>

Re: Initializing multiple VelocityServlets

Posted by "Kaur, Jasdeep Guglani" <ja...@gmail.com>.
Please reply....what steps are needed tp move from VelocityServlet to
VelocityViewServlet.

I downloaded the jar velocity-tools-view-1.4.jar. and extended my VMServlet
class from velocityViewServlet. what other changes are required.

Please guide its urgent.


On 1/23/08, Kaur, Jasdeep Guglani <ja...@gmail.com> wrote:
>
> Hi Thanks for responding...
>
> If I have to use Velocity Servlet...can this problem be rectified....
>
>
>  On 1/23/08, Will Glass-Husain <wg...@forio.com> wrote:
> >
> > Hi,
> >
> > Have you looked at the Velocity Tools subproject?  Look at the
> > VelocityViewServlet.  It's a much better servlet and is actively
> > maintained.
> >
> > Let's take any other discussion to the user@velocity.apache.org
> > mailing list please.
> >
> > WILL
> >
> > On 1/23/08, Kaur, Jasdeep Guglani < jasdeepkg@gmail.com> wrote:
> > > Hi
> > >
> > > I wish to use the code written by. Attcahed is the file you wrote. It
> > has
> > > alternate version of the Velocity servlet to load multiple instances.
> > >
> > > I extend this class and want multiple instances of the subclass too.
> > Is it
> > > possible? or how else can I proceed to wards it...
> > >
> > >
> > >
> > > I can quote my problem in following way:
> > >
> > > There is a servlet (VMServlet) that handles all our requests. It has a
> > > member variable viz. "user" that stores the username etc. As we are
> > using
> > > singleton model; only one copy of the VMServlet class gets created.
> > >
> > >
> > >
> > > So when multiple users log into the application, and there is one
> > instance
> > > of the VMServlet which is handling the requests, we see wrong user
> > name in
> > > the application. This problem appears when more than one instance of
> > the
> > > application are  busy processing simulataneously.
> > >
> > >  The VM Servlet class extends VelocityServlet.
> > >
> > >
> > >
> > > In VelocityServlet class I made some change to drop the singleton
> > model
> > > being followed earliar.
> > >
> > > The change is
> > >
> > > protected void initVelocity(ServletConfig config)
> > >
> > >         throws ServletException
> > >
> > >     {
> > >
> > >         try
> > >
> > >         {
> > >
> > >             Properties props = loadConfiguration(config);
> > >
> > >             //Velocity.init(props); This line was commented
> > >
> > >
> > >
> > >             /* Code inserted */
> > >
> > > ve = new VelocityEngine();
> > >
> > >                   System.out.println("\n\n\n*************In Velocity
> > Servlet
> > > Modified****************");
> > >
> > >             ve.init(props);
> > >
> > >         }
> > >
> > >         catch(Exception e)
> > >
> > >         {
> > >
> > >             throw new ServletException("Error initializing Velocity: "
> > + e,
> > > e);
> > >
> > >         }
> > >
> > >     }
> > >
> > > But this has not solved the problem.
> > >
> > >
> > >
> > > Do you have any idea how to go about it? your alternate velocity
> > servlet has
> > > not solved my problem.
> > >
> > > Please help...n thanks!
> > >
> > >
> > >
> >
> >
> > --
> > Forio Business Simulations
> >
> > Will Glass-Husain
> > 415 440-7500x89
> > wglass@forio.com
> > www.forio.com
> >
>
>