velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garey Mills <gmi...@library.berkeley.edu>
Subject Integrating VelocityViewServlet with Guice
Date Tue, 05 Apr 2011 19:02:18 GMT
Hi -

     I am trying to integrate VelocityViewServlet and Guice 3.0. I am 
having a problem because VelocityViewServlet does
not seem to see what I am putting into the context to forward to it.


     Guice intercepts all access points. You write a 'ServletModule' 
that forwards different URL patterns to different servlets.

      Guice requires servlets to annotated as Singletons, or to be bound 
to singleton scope in the 'ServletModule'. Here is my
servlet module

...

     protected void configureServlets() {

     bind(VelocityViewServlet.class).in(Singleton.class);

     serve("*.vm").with(VelocityViewServlet.class);

     serve("/gisform").with(GisFormServlet.class);

  }

...

In my GisFormServlet,

...
         HttpSession hs = req.getSession();

         ServletContext sc = hs.getServletContext();

         sc.setAttribute("GISVALUE", "Hello, I'm GISVALUE");


         String next = "/submission/submission.form.vm";
         RequestDispatcher dispatcher = 
getServletContext().getRequestDispatcher(next);
         dispatcher.forward(req,resp);
...

I have also put GISVALUE into the request and into the HttpSession. In 
every case, my simple submission.form.vm

<html>

<body>

         $GISVALUE

</body>

</html>



outputs '$GISVALUE'. No substitution is occurring.


     Has anyone tried to integrate VelocityViewServlet and Guice? Does 
anyone have any insight into how to fix this, or even how to debug it?

Any help appreciated;

Garey Mills
Library Systems Office
UC Berkeley

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


Mime
View raw message