cancel
Showing results for 
Search instead for 
Did you mean: 

Browser Detection in Web Dynpro

Former Member
0 Kudos

Dear All,

I am developing an application which would be used from a BlackBerry browser as well as a PC browser.

I there a way to detect which browser has been used for opening the applicaion?

I need this because I would be using 2 different layouts for the 2 cases.

I found some ways of detecting the browser:

1) TaskBinder.getCurrentTask().getClient().getClientDescription().getName().

But this should not be used as it is not an API.

2) WDProtocolAdapter.getProtocolAdapter().getRequestObject().getProtocolRequest()

But it is not supported now I suppose. We are using NWDS 7.0.17.

Please suggest a solution.

Thanks and regards,

Mayuresh

Edited by: Mayuresh Kanvinde on Jan 22, 2009 12:19 PM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Kind of figured out that detecting the browser from web dynpro directly would be tough.

I am temporarily using a jsp which detects the browser and then redirects accordingly to the web dynpro url depending on the browser (Blackberry or PC like IE etc).

Still if anyone does know or find a solution to detect it directly from web dynpro please do post it.

Thanks and regards,

Mayuresh

Former Member
0 Kudos

Hi Friend,

Thanks for the reply.

I tried it but it gives the properties of the java runtime and that too of the server where the application runs (which is not a surprise).

For the code System.getProperty("java.vendor"),

it returned Sun Microsystems Inc. even though I had used Internet Explorer.

Also, no other property returns any value pertaining to Microsoft of IE.

Do you know any other way?

Thanks and regards,

Mayuresh

Edited by: Mayuresh Kanvinde on Jan 27, 2009 6:24 PM

Edited by: Mayuresh Kanvinde on Jan 27, 2009 6:34 PM

Edited by: Mayuresh Kanvinde on Jan 27, 2009 6:36 PM

p_2_5_6_9_6_0
Active Participant
0 Kudos

Hi,

Yes - it will always give you the server side properties.

If you are using JSP - the code is :

String ua = request.getHeader( "User-Agent" );

boolean isFirefox = ( ua != null && ua.indexOf( "Firefox/" ) != -1 );

boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 );

response.setHeader( "Vary", "User-Agent" );

Unfortunately the Portal Code I am not aware of. But it would probably work by first getting the request made by the user (like the JSP Request object), then calling various methods of the request object.

Thanks,

p256960.

p_2_5_6_9_6_0
Active Participant
0 Kudos

Hi,

I have a piece of Java code that will work:

String browser = System.getProperty( "java.vendor" );

if( browser.indexOf( "Netscape" ) != -1 )
    {
      System.out.println( "Netscape broswer!" );
    }
    else if( browser.indexOf( "Sun" ) != -1 )
    {
      System.out.println( "Applet Viewer!" );
    }
    else if( browser.indexOf( "Microsoft" ) != -1 )
    {
      System.out.println( "IE broswer!" );
    }

Hope that helps.

Thanks.

p256960.