Skip to Content
0
Former Member
Jan 25, 2008 at 04:22 PM

Identifying browser/device

12 Views

Hello all.

Is there a way to identify a browser or device in runtime? I want to write a piece of code that checks if the user is accessing the application through a normal browser (IE/Firefox) or using a mobile device (Blackberry), so my app can redirect to a more complex UI in case of ordinary browsers or to a simpler UI (fewer fields) in case of a mobile device.

I tried this without success:

ClientInfoFactory factory = ClientInfoFactory.newInstance();

ClientInfo clientInfo = factory.newClientInfo();

IWDProtocolAdapter protAdapter = WDProtocolAdapter.getProtocolAdapter();

IWDRequest request = protAdapter.getRequestObject();

clientInfo.load(request);

String deviceName = clientInfo.getDeviceName();

I get ClassNotFoundException or NullPointerException depending on how clientinfo.jar is referrenced in the project.

Anyone knows any solution to this? Any help is appreciated,

regards,

Paulo.