I created a JSF application which also offers some Webservices. The webservices are created via annotations.
Now I want to create a webserviceInfo.xhtml Page , where I get all the needed webservice Information.
When I go to the address http://our.server.com/application/OurWebserviceName, I get all the information needed to access the webservice (this info page is generated automatically by Glassfish ).
To include this page, I did the following in the webserviceInfo.xhtml:
<iframe scrolling="automatic" width="971" height="1000" src="#{myBean.generateUrlToWebservice()}/OurWebserviceName"/>
Where:
public String generateUrlToWebservice(){
FacesContext fc = FacesContext.getCurrentInstance();
String servername = fc.getExternalContext().getRequestServerName();
String port = String.valueOf(fc.getExternalContext().getRequestServerPort());
String appname = fc.getExternalContext().getRequestContextPath();
return "http://"+servername+":"+port+appname;
}
Is there a more elegant solution to this?
BR, Rene
Use a page-relative URL.
Or make use of
<base>tag with little help of JSTLfunctionstaglib.This way any URL which doesn’t start with scheme or
/is always relative to this URL.Or if you really need to do it in JSF the following gives less headache with scheme and port.