I have a jsp page which needs a java code.
This java code inside jsp needs a service class.
Now my service class is java gets created using spring DI and DAO & other things are injected in service class using Spring.
But when i want to use it in jsp, how should I ask spring to provide me the object of service inside jsp?
JSP -> Java Code -> Service -> DAO
I am using struts2 & spring DI as frameworks.
You can create a class that is Spring-managed and application context aware. This class will provide Spring bean via static methods from anywhere in your code.
From anywhere in your code, use
SpringBeansProvider.getBean("myBean", MyBean.class). Yes, this breaks down a concept of beans injection and mixes up static and non-static methods usage, but such kind of task always cause those unfair things.