AdDynamo wrote:Would one only need to use the GeneralWURFLEngine for this?
Of course.
The method
Code: Select all
public Device GeneralWURFLEngine.getDeviceForRequest(HttpServletRequest request)
does everything, taking as the only parameter the
HttpServletRequest you get from the
HttpServlet.doGet and
doPost methods.
The servlet example provided with the Java API has one only
HttpServlet, hence it owns all the code for simplicity.
Nevertheless, it already shows how to instantiate a
GeneralWURFLEngine at initialization time, and share it to all servlets belonging to the web application through the
ServletContext, so that the device matching can be performed by one single (though quite cumbersome) line of code:
Code: Select all
Device device = ((GeneralWURFLEngine)getServletContext().getAttribute(WurflWebConstants.WURFL_HOLDER_KEY_PARAM)).getDeviceForRequest(request);
For this purpose, see the class
net.sourceforge.wurfl.core.web.WURFLServletContextListener, which is part of the WURFL core, so that it is ready to be used by your web application.
If I did not answered your question, maybe I did not understand what you mean by
AdDynamo wrote:without implementing it inside a servlet (as in all the examples)
Just please describe what you would like to avoid in each Servlet, and I will be glad to help you further.
Regards,
Fulvio