Author: azeez Date: Thu Jan 6 06:36:40 2011 New Revision: 1055758 URL: http://svn.apache.org/viewvc?rev=1055758&view=rev Log: Applying patch provided by Boris Milonov for AXIS2-4461
Modified: axis/axis2/java/core/trunk/modules/webapp/src/main/webapp/axis2-web/include/httpbase.jsp Modified: axis/axis2/java/core/trunk/modules/webapp/src/main/webapp/axis2-web/include/httpbase.jsp URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/webapp/src/main/webapp/axis2-web/include/httpbase.jsp?rev=1055758&r1=1055757&r2=1055758&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/webapp/src/main/webapp/axis2-web/include/httpbase.jsp (original) +++ axis/axis2/java/core/trunk/modules/webapp/src/main/webapp/axis2-web/include/httpbase.jsp Thu Jan 6 06:36:40 2011 @@ -17,76 +17,55 @@ ~ under the License. --%> -<%@ page import="org.apache.axis2.AxisFault" %> <%@ page import="org.apache.axis2.Constants" %> -<%@ page import="org.apache.axis2.addressing.EndpointReference" %> -<%@ page import="org.apache.axis2.client.Options" %> -<%@ page import="org.apache.axis2.client.ServiceClient" %> <%@ page import="org.apache.axis2.context.ConfigurationContext" %> -<%@ page import="org.apache.axis2.context.ConfigurationContextFactory" %> -<%@ page import="org.apache.axis2.context.ServiceContext" %> -<%@ page import="org.apache.axis2.context.ServiceGroupContext" %> -<%@ page import="org.apache.axis2.deployment.util.PhasesInfo" %> -<%@ page import="org.apache.axis2.description.AxisModule" %> -<%@ page import="org.apache.axis2.description.AxisOperation" %> -<%@ page import="org.apache.axis2.description.AxisService" %> -<%@ page import="org.apache.axis2.description.AxisServiceGroup" %> <%@ page import="org.apache.axis2.description.Parameter" %> -<%@ page import="org.apache.axis2.engine.AxisConfiguration" %> -<%@ page import="org.apache.axis2.engine.Handler" %> -<%@ page import="org.apache.axis2.engine.Phase" %> <%@ page import="org.apache.axis2.transport.http.AxisServlet" %> -<%@ page import="org.apache.axis2.util.JavaUtils" %> -<%@ page import="javax.xml.parsers.SAXParser" %> -<%@ page import="javax.xml.parsers.SAXParserFactory" %> -<%@ page import="java.io.IOException" %> -<%@ page import="java.io.InputStream" %> -<%@ page import="java.io.StringWriter" %> -<%@ page import="java.util.ArrayList" %> -<%@ page import="java.util.Collection" %> -<%@ page import="java.util.Enumeration" %> -<%@ page import="java.util.HashMap" %> -<%@ page import="java.util.Hashtable" %> -<%@ page import="java.util.Iterator" %> +<%@ page import="org.apache.axis2.transport.TransportListener" %> <%! - private String frontendHostUrl; + private String frontendHostUrl; + private String hostname; - public void jspInit() { - ServletContext context = this.getServletConfig().getServletContext(); - ConfigurationContext configctx = (ConfigurationContext) context.getAttribute(AxisServlet.CONFIGURATION_CONTEXT); - if (configctx != null){ - Parameter parameter = configctx.getAxisConfiguration().getParameter(Constants.HTTP_FRONTEND_HOST_URL); - if (parameter != null) { - frontendHostUrl = (String) parameter.getValue(); + public void jspInit() { + ServletContext context = this.getServletConfig().getServletContext(); + ConfigurationContext configctx = (ConfigurationContext) context.getAttribute(AxisServlet.CONFIGURATION_CONTEXT); + if (configctx != null) { + Parameter parameter = configctx.getAxisConfiguration().getParameter(Constants.HTTP_FRONTEND_HOST_URL); + if (parameter != null) { + frontendHostUrl = (String) parameter.getValue(); + } + Parameter hostnameParam = configctx.getAxisConfiguration().getParameter(TransportListener.HOST_ADDRESS); + if (hostnameParam != null) { + hostname = (String) hostnameParam.getValue(); + } } } - } - public String calculateHttpBase(HttpServletRequest aRequest) { - StringBuffer stringBuffer = new StringBuffer(); - if (frontendHostUrl != null) { - stringBuffer.append(frontendHostUrl); - } else { - String scheme = aRequest.getScheme(); - stringBuffer.append(scheme); - stringBuffer.append("://"); - stringBuffer.append(aRequest.getServerName()); - if (("http".equalsIgnoreCase(scheme) && aRequest.getServerPort() != 80) || "https".equalsIgnoreCase(scheme) && aRequest.getServerPort() != 443) - { - stringBuffer.append(":"); - stringBuffer.append(aRequest.getServerPort()); - } - // I think i saw web containers return null for root web context - if (aRequest.getContextPath() != null) { - stringBuffer.append(aRequest.getContextPath()); - } - } - // append / char if needed - if (stringBuffer.charAt(stringBuffer.length() - 1) != '/') { - stringBuffer.append("/"); + public String calculateHttpBase(HttpServletRequest aRequest) { + StringBuffer stringBuffer = new StringBuffer(); + if (frontendHostUrl != null) { + stringBuffer.append(frontendHostUrl); + } else { + String scheme = aRequest.getScheme(); + stringBuffer.append(scheme); + stringBuffer.append("://"); + stringBuffer.append(hostname != null ? hostname : aRequest.getServerName()); + if (("http".equalsIgnoreCase(scheme) && aRequest.getServerPort() != 80) || "https".equalsIgnoreCase(scheme) && aRequest.getServerPort() != 443) { + stringBuffer.append(":"); + stringBuffer.append(aRequest.getServerPort()); + } + // I think i saw web containers return null for root web context + if (aRequest.getContextPath() != null) { + stringBuffer.append(aRequest.getContextPath()); + } + } + // append / char if needed + if (stringBuffer.charAt(stringBuffer.length() - 1) != '/') { + stringBuffer.append("/"); + } + String curentUrl = stringBuffer.toString(); + aRequest.setAttribute("frontendHostUrl", curentUrl); + return curentUrl; } - String curentUrl = stringBuffer.toString(); - aRequest.setAttribute("frontendHostUrl", curentUrl); - return curentUrl; - } -%><base href="<%= calculateHttpBase(request)%>"/> \ No newline at end of file +%> +<base href="<%= calculateHttpBase(request)%>"/> \ No newline at end of file