source: gs3-extensions/pharos/trunk/web/axis2-web/include/httpbase.jsp@ 20983

Last change on this file since 20983 was 20983, checked in by davidb, 14 years ago

Initial files for Phrasos extension to Greenstone3

File size: 4.0 KB
Line 
1<%--
2 ~ Licensed to the Apache Software Foundation (ASF) under one
3 ~ or more contributor license agreements. See the NOTICE file
4 ~ distributed with this work for additional information
5 ~ regarding copyright ownership. The ASF licenses this file
6 ~ to you under the Apache License, Version 2.0 (the
7 ~ "License"); you may not use this file except in compliance
8 ~ with the License. You may obtain a copy of the License at
9 ~
10 ~ http://www.apache.org/licenses/LICENSE-2.0
11 ~
12 ~ Unless required by applicable law or agreed to in writing,
13 ~ software distributed under the License is distributed on an
14 ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ~ KIND, either express or implied. See the License for the
16 ~ specific language governing permissions and limitations
17 ~ under the License.
18 --%>
19
20<%@ page import="org.apache.axis2.AxisFault" %>
21<%@ page import="org.apache.axis2.Constants" %>
22<%@ page import="org.apache.axis2.addressing.EndpointReference" %>
23<%@ page import="org.apache.axis2.client.Options" %>
24<%@ page import="org.apache.axis2.client.ServiceClient" %>
25<%@ page import="org.apache.axis2.context.ConfigurationContext" %>
26<%@ page import="org.apache.axis2.context.ConfigurationContextFactory" %>
27<%@ page import="org.apache.axis2.context.ServiceContext" %>
28<%@ page import="org.apache.axis2.context.ServiceGroupContext" %>
29<%@ page import="org.apache.axis2.deployment.util.PhasesInfo" %>
30<%@ page import="org.apache.axis2.description.AxisModule" %>
31<%@ page import="org.apache.axis2.description.AxisOperation" %>
32<%@ page import="org.apache.axis2.description.AxisService" %>
33<%@ page import="org.apache.axis2.description.AxisServiceGroup" %>
34<%@ page import="org.apache.axis2.description.Parameter" %>
35<%@ page import="org.apache.axis2.engine.AxisConfiguration" %>
36<%@ page import="org.apache.axis2.engine.Handler" %>
37<%@ page import="org.apache.axis2.engine.Phase" %>
38<%@ page import="org.apache.axis2.transport.http.AxisServlet" %>
39<%@ page import="org.apache.axis2.util.JavaUtils" %>
40<%@ page import="javax.xml.parsers.SAXParser" %>
41<%@ page import="javax.xml.parsers.SAXParserFactory" %>
42<%@ page import="java.io.IOException" %>
43<%@ page import="java.io.InputStream" %>
44<%@ page import="java.io.StringWriter" %>
45<%@ page import="java.util.ArrayList" %>
46<%@ page import="java.util.Collection" %>
47<%@ page import="java.util.Enumeration" %>
48<%@ page import="java.util.HashMap" %>
49<%@ page import="java.util.Hashtable" %>
50<%@ page import="java.util.Iterator" %>
51<%!
52 private String frontendHostUrl;
53
54 public void jspInit() {
55 ServletContext context = this.getServletConfig().getServletContext();
56 ConfigurationContext configctx = (ConfigurationContext) context.getAttribute(AxisServlet.CONFIGURATION_CONTEXT);
57 if (configctx != null){
58 Parameter parameter = configctx.getAxisConfiguration().getParameter(Constants.HTTP_FRONTEND_HOST_URL);
59 if (parameter != null) {
60 frontendHostUrl = (String) parameter.getValue();
61 }
62 }
63 }
64
65 public String calculateHttpBase(HttpServletRequest aRequest) {
66 StringBuffer stringBuffer = new StringBuffer();
67 if (frontendHostUrl != null) {
68 stringBuffer.append(frontendHostUrl);
69 } else {
70 String scheme = aRequest.getScheme();
71 stringBuffer.append(scheme);
72 stringBuffer.append("://");
73 stringBuffer.append(aRequest.getServerName());
74 if (("http".equalsIgnoreCase(scheme) && aRequest.getServerPort() != 80) || "https".equalsIgnoreCase(scheme) && aRequest.getServerPort() != 443)
75 {
76 stringBuffer.append(":");
77 stringBuffer.append(aRequest.getServerPort());
78 }
79 // I think i saw web containers return null for root web context
80 if (aRequest.getContextPath() != null) {
81 stringBuffer.append(aRequest.getContextPath());
82 }
83 }
84 // append / char if needed
85 if (stringBuffer.charAt(stringBuffer.length() - 1) != '/') {
86 stringBuffer.append("/");
87 }
88 String curentUrl = stringBuffer.toString();
89 aRequest.setAttribute("frontendHostUrl", curentUrl);
90 return curentUrl;
91 }
92%><base href="<%= calculateHttpBase(request)%>"/>
Note: See TracBrowser for help on using the repository browser.