cancel
Showing results for 
Search instead for 
Did you mean: 

Get User Agent

Former Member
0 Kudos

Hi All,

Every time you get an error, the Web dynpro always show something like this.

System Environment

Client

Web Dynpro Client Type HTML Client

User agent Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)

etc...

My question is, How can I get this info form the WD? How can I get the User Agent form the WD.

Regards,

Orlando Covault

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

It is possible (with the risk of your application becoming non platform-independent):


HttpServletRequest request = WDProtocolAdapter.getProtocolAdapter().getRequestObject().getProtocolRequest();
	  
String userAgent = request.getHeader("User-Agent");

You will need to add either "servlet.jar" file to the class path or add a DC dependency to SERVERCORE/servlet (if you are on CE). The above code runs on CE and I'm not sure about backward compatibity.

For those who are going to argue that using "HttpServletRequest" within WD is forbidden, here's the javadoc of the "getProtocolRequest()" method:

>Object com.sap.tc.webdynpro.services.sal.adapter.api.IWDRequest.getProtocolRequest()

>

>Returns the original request object of the used transport protocol and platform.

>When using this method, a cast to the specific request object is necessary, e.g. a cast to HttpServletRequest. When an application does this, it might no longer be platform independent.

Regards,

Satyajit.

Former Member
0 Kudos

Hi Satyajith

Where should I add this code in the application?

Former Member
0 Kudos

Hi Satyajit,

I thought that I need the "servlet.jar" in order to use the HttpServletRequest. But I can´t get it because there is no getProtocolRequest in the IWDRequest.

Maybe I misunderstood. Could you give me more guidelines.

Regards,

Orlando Covault

Former Member
0 Kudos

Hi All,

Has anyone been able to resolve this? I am facing the same problem where we used TaskBinder.getCurrentTask(). getWebContextAdapter() to access cookies in ep6 but now in 2004s cannot find a way around this. I also wish to link in with mss team viewer. I can of course subscribe to the event but it will not take the initial value this is why I was acessing the databag.

Any help appreciated.

Regards,

Niall

Former Member
0 Kudos

Hi,

Webdypro uses it internally as part of its phase model. I think its not accessible from wd by code.

regards

Ayyapparaj