cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve the protocol (http / https) from WDJ application URL

srinivas_sistu
Active Contributor
0 Kudos

Hi All,

In my WDJ component, I need to get the ServerName, Port and the protocol (http / https) from the WDJ application URL. I am able to get the server name and the port but unable to get the protocol. Any help would be highly appreciated.

Code I am using is :

String ServerName = WDProtocolAdapter.getProtocolAdapter().getRequestObject().getServerName();

String port = WDProtocolAdapter.getProtocolAdapter().getRequestObject().getServerPort();

Regards,

Srinivas Sistu

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Hey got the solution for this,

Get the URL of Application in WD java :

String URL=WDURLGenerator.getAbsoluteWebResourceURL(wdComponentAPI.getApplication().getDeployableObjectPart());

  wdComponentAPI.getMessageManager().reportSuccess("URL:"+URL);

This will return the FINAL server URL.

Checked with both http:// and https:// links of my server.

In my case https:// link is redirecting to FQDN URL(http://) of my server, so it worked.

Please mark it correct if it works for you.

Former Member
0 Kudos

Hi Srinivas,

Did you get any solution. Pls share if any.

janncors11
Explorer
0 Kudos

Hello,

The interface ServletRequest has the following methods:

getProtocol:  Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.

getSchema: Returns the name of the scheme used to make this request, for example, http, https, or ftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738.

IWDRequest request = WDProtocolAdapter.getProtocolAdapter().getRequestObject();

HttpServletRequest httpRequest = (HttpServletRequest) WDProtocolAdapter

       .getProtocolAdapter().getRequestObject().getProtocolRequest();

String protocol = httpRequest.getScheme();

String url = protocol + "://" + request.getServerName() + ":" + request.getServerPort();

msgManager.reportSuccess(url);

Regards,

Jann Cortés