I\'m new in Spring and want to connect spring ioc into my small(test) web-app.
I have such Servlet ProductServlet
:
public class Product
Here is a solution, which might help you:
public class ProductServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
private RequestHelper requestHelper = null;
private requestHelperInit(HttpServletRequest request)
{
if(requestHelper == null)
{
ApplicationContext ap = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
requestHelper = ap.getBean(RequestHelper.class);
}
}
}
Then call requestHelperInit(request)
method in either your doGet()
or doPost()
method as the first statement.
If you are still looking for a solution, then I hope this will help you out.