Questions tagged [guice-servlet]

Guice's servlet extensions allow you to completely eliminate web.xml from your servlet application and take advantage of type-safe, idiomatic Java configuration of your servlet and filter components

Guice Servlet Extensions

Guice Servlet provides a complete story for use in web applications and servlet containers. Guice's servlet extensions allow you to completely eliminate web.xml from your servlet application and take advantage of type-safe, idiomatic Java configuration of your servlet and filter components.

This has advantages not only in being able to use a nicer API for configuring your web applications, but also in tying together dependency injection with web components. Meaning that your servlets and filters benefit from:

  • Constructor injection
  • Type-safe, idiomatic configuration
  • Modularization (package and distribute custom Guice Servlet libraries)
  • Guice AOP

While keeping the benefits of the standard servlet lifecycle.

References

100 questions
1
vote
2 answers

guice - Provider returns always same instance

I am working with guice 3 and guice-servlet 3. In the module I defined bindings of this…
Christian
  • 3,503
  • 1
  • 26
  • 47
1
vote
1 answer

Testing filters with jetty

I've configured my servlets/filters using guice-servlet. With bindings like serve("/foo").with(HelloServlet.class); Now, I want to test that mapping. I've used jetty-testing private ServletTester tester; private HttpTester request; private…
Stan Kurilin
  • 15,614
  • 21
  • 81
  • 132
1
vote
2 answers

How to serve JSPs using Guice 3.0?

I'm trying to serve a JSP from Guice. I don't find any basic examples on how to do this! My setup : web.xml guiceFilter
electrotype
  • 8,342
  • 11
  • 59
  • 96
1
vote
1 answer

Guice, Peaberry and ServletModule

I am having an issue getting Peaberry/Guice/OSGi/Servlets to place nice. To begin, I have been migrating a Jetty-based, WAR deployed webapp over to OSGi to leverage the plugin architecture. My original application was using guice everywhere. I have…
Evan Ruff
  • 582
  • 7
  • 21
1
vote
2 answers

Is there a way to handle extra slashes at beginning of url using jersey and guice?

I have a REST api put together using jersey and guice for dependency injection. Everything works great, I have FEATURE_CANONICALIZE_URI_PATH and FEATURE_NORMALIZE_URI turned on and that handles extra slashes in almost all cases. For…
mockobject
  • 1,797
  • 16
  • 26
0
votes
1 answer

Guice 3.0 request.getRequestDispatcher(..).forward prepending guice servlet path

We are using JBoss 5.1 with Guice 3.0 and need to forward from our Guice servlet to an external Servlet using the following technique: @Inject HttpServletRequest request; @Inject HttpServletResponse…
JStark
  • 2,788
  • 2
  • 29
  • 37
0
votes
1 answer

bindInterceptor vs filter for guice security?

I have a simple use case where I want to grab a session variable at the beginning of the session and only allow access to certain pages based on the result. I'm not real clear on is this best accomplished using bindInterceptor to intercept any @Get…
JStark
  • 2,788
  • 2
  • 29
  • 37
0
votes
2 answers

GWT Fileupload Using Servlet with GUICE

We are using GWTP with Guice. I want to upload a file. For that I have written a Servlet. I am using this GWT File UPload Example. But Servlet is not getting called. I think its the problem with GuiceFilter. Below is my web.xml…
Hardik Mishra
  • 14,779
  • 9
  • 61
  • 96
0
votes
1 answer

Guice servlet 405 err: seems to not set Content-type set to "text/json" for MediaType.APPLICATION_JSON

I'm making a call from jQGrid to a Guice servlet that has the following binding: @Produces({MediaType.APPLICATION_JSON}) @Path("/{param}") public String getJson(@PathParam("param") String param) { ... return return…
JStark
  • 2,788
  • 2
  • 29
  • 37
0
votes
1 answer

How can we disable a guice filter at runtime or on application startup?

I have multiple filters defined in my Google guice application. But is there a way I can disable certain filters at runtime or on application startup? bind(MyService.class).to(MyServiceImpl.class); filter("/*").through(MyFilter.class); …
Jaraws
  • 581
  • 1
  • 7
  • 24
0
votes
1 answer

Clear a session scoped object in Guice Servlet

Currently I have a session scoped object called MySessionData. Originally when logging out I just called getThreadLocalRequest().getSession().invalidate(); The problem is now we have multiple session scoped objects and logging out only really…
benstpierre
  • 32,833
  • 51
  • 177
  • 288
0
votes
1 answer

Servlet encoding globally using maven + guice

In my project, I'm using Maven + Google Guice + Java 8, and I checked that my webpage responses were not encoded and the problem is from the backend side. The solution I found to fix it was to update the HttpServletResponse: @Override public void…
Vítor Resende
  • 230
  • 3
  • 16
0
votes
1 answer

How to get TypeLiteral binding or can say instance from injector [Google Guice]

I have Dao interface which is implemented by BaseDao class & BaseDao later extended by many of subclass like UserDao class. interface Dao{} abstract class BaseDao implements Dao{} class UserDao extends BaseDao{} Following…
Swapnil Patil
  • 613
  • 6
  • 23
0
votes
0 answers

how to use guice correctly for dependency inject in java servlets?

sorry for the bad question title... Disclaimer: Not much experience around web-apps, primarily used dropwizard. So i have been trying to use guice in my java web-app Initially without guice, servlets were serving the api correctly but after…
NoobEditor
  • 15,563
  • 19
  • 81
  • 112
0
votes
1 answer

Problem with configuring servletModule with Guice injecting GWT RequestFactory

I want to use GUICE on the server side with the GWT 2.3 RequestFactory. I have my class that extends the ServletModule with : @Override public void configureServlets() { // RequestFactory servlet …
Gerald
  • 101
  • 1
  • 10