The Web Content Application 2 WAR Module packages all the other modules with default servlet/filter/portlet configurations and demonstration-purpose examples.
If you use Apache Maven in your project, then you can add the following dependency to use this module in your project.
<dependency> <groupId>org.apache.portals.applications</groupId> <artifactId>apa-webcontent2-war</artifactId> <type>war</type> <version>${webcontent2.version}</version> </dependency>
The Web Content Application 2 WAR Module contains a reverse proxy servlet definition like the following in /WEB-INF/web.xml by default.
<!-- Default Reverse Proxy Servlet --> <servlet> <servlet-name>ReverseProxyServlet</servlet-name> <servlet-class>org.apache.portals.applications.webcontent2.proxy.servlet.SimpleReverseProxyServlet</servlet-class> <init-param> <param-name>mappings</param-name> <param-value> /WEB-INF/rproxy-mappings.yaml </param-value> </init-param> <init-param> <param-name>ssl-hostname-verifier</param-name> <param-value>ALLOW_ALL_HOSTNAME_VERIFIER</param-value> </init-param> </servlet> <!-- Map /rproxy path to the Default Reverse Proxy Servlet --> <servlet-mapping> <servlet-name>ReverseProxyServlet</servlet-name> <url-pattern>/rproxy/*</url-pattern> </servlet-mapping>
The mapping configuration for the servlet is configured in /WEB-INF/rproxy-mappings.yaml by default:
--- !regex localPattern: ^/localhost_(\d+)/(.*)$ remoteReplace: http://localhost:$1/$2 remotePattern: ^http://localhost:(\d+)/(.*)$ localReplace: /localhost_$1/$2 contentRewriters: text/html: !!org.apache.portals.applications.webcontent2.proxy.rewriter.DefaultReverseProxyTextLineContentRewriter [] --- !simple local: /portals/applications/ remote: http://portals.apache.org/applications/ contentRewriters: text/html: !!org.apache.portals.applications.webcontent2.proxy.rewriter.DefaultReverseProxyTextLineContentRewriter [] --- !simple local: /portals/bridges/ remote: http://portals.apache.org/bridges/ contentRewriters: text/html: !!org.apache.portals.applications.webcontent2.proxy.rewriter.DefaultReverseProxyTextLineContentRewriter [] --- !regex localPattern: ^/apache/(\w+)/(.*)$ remoteReplace: http://$1.apache.org/$2 remotePattern: ^http://(\w+)\.apache\.org/(.*)$ localReplace: /apache/$1/$2 contentRewriters: text/html: !!org.apache.portals.applications.webcontent2.proxy.rewriter.DefaultReverseProxyTextLineContentRewriter [] --- !simple local: / remote: http://apache.org/ contentRewriters: text/html: !!org.apache.portals.applications.webcontent2.proxy.rewriter.DefaultReverseProxyTextLineContentRewriter []
The Web Content Application 2 WAR Module contains several portlet definitions in /WEB-INF/portlet.xml:
The IFrame Portet 2 achieves this by embedding an HTML iframe within a portlet.
The ReverseProxy IFrame Portlet 2 behaves in the same way as IFrame Portlet 2 does, except that it uses reverse proxy service URLs instead of the original SRC URLs. By using Reverse Proxy service component, more sophisticated content can be served by setting content rewriting configurations or Cross-Domain Scripting can be enabled. The Web Content Application includes Reverse Proxy Service servlet and component.
The Web Content Portlet 2 takes a more complicated approach: it actually embeds the content of the remote website inside the HTML payload delivered by the portal, without the help of the browser. This approach is more complicated since it may require rewriting all links within the hosted website, that is, if you want to keep the website navigation inside the portlet window. While a noble cause, this approach is far from perfect and does not always work correctly.
The SimpleReverseProxyPortlet behaves in the same way as Reverse Proxy Servlet or Filter by itself without having to depend on an external reverse proxy servlet or filter. This portlet also rewrite all the links to portlet action URLs like Web Content Portlet 2 does. This simple reverse proxying portlet can be used as a base class that you can extend or as an example.
If you are interested in secure versions of these portlets, see the Jetspeed-specific versions of the IFrame 2, ReverseProxyIFrame 2, or WebContent 2 portlets found at the Jetspeed J2-Admin website. The SSOIFrame, SSOReverseProxyIFrame and SSOWebContent portlets leverage the Jetspeed SSO Services, and are not portable to other portal servers.
Here are the classes to declare when using the portlets:
<portlet-class>org.apache.portals.applications.webcontent2.portlet.IFrameGenericPortlet</portlet-class>
Note: The ReverseProxyIFramePortlet uses the same class, but has different preferences configurations.
or
<portlet-class>org.apache.portals.applications.webcontent2.portlet.WebContentPortlet</portlet-class>
Name | Type | Example Value | Description |
---|---|---|---|
SRC | Preference | http://www.google.com | The URL of the remote or local site to be hosted. |
PROXYHOST | Preference | proxyserver1.mycompany.com | The proxy server host name. |
PROXYPORT | Preference | 8000 | The proxy server port. |
Name | Type | Example Value | Description |
---|---|---|---|
SRC | Preference |
http://portals.apache.org/index.html |
The URL of the remote or local site to be hosted.
You can use predefined variables, ${serverName}, ${serverPort} or ${contextPath}, to set local URLs.
|
AUTORESIZE | Preference | true | If this preference value is set to true, then this portlet tries to resize the height of the IFRAME tag based on the rendered content. However, this option is applied only when the 'SRC' url is in the same domain of the portal URL. |
VISITLASTPAGE | Preference | true | If this preference value is set to true, then this last visited page in this portlet is stored in the session and the page will be revisited when the portlet is rendered again. However, this option is applied only when the 'SRC' url is in the same domain of the portal URL. |
HEIGHT | Preference | 300 | The height of the IFrame window when in Normal Window State |
WIDTH | Preference | 100% | The width of the IFrame window when in Normal Window State. Can be a percentage of available space to the portlet, or a constant value |
MAX-HEIGHT | Preference | 800 | The height of the IFrame window when in Maximized Window State |
MAX-WIDTH | Preference | 100% | The width of the IFrame window when in Maximized Window State. Can be a percentage of available space to the portlet, or a constant value |
SCROLLING | Preference | AUTO | YES | NO | Specifies whether or not to display scrollbars in an iframe |
Note: The ReverseProxyService should be able to access application level session attribute shared by a portlet of IFrameGenericPortlet or its descendant, which is conforming with the Portlet Specification. If you are using Tomcat, then be sure to set the following in the server.xml to enable this proper Portlet API session management requirements. Modify the Connector element (default on port 8080) by adding the folowing attribute:
emptySessionPath="true"
Name | Type | Example Value | Description |
---|---|---|---|
SRC | Preference | http://portals.apache.org/index.html |
The URL of the remote or local site to be hosted.
You can use predefined variables, ${serverName}, ${serverPort} or ${contextPath}, to set local URLs.
|
PROXYREMOTEURL | Preference | http://portals.apache.org/ |
The base URL of the remote site.
If 'PROXYREMOTEURL' and 'PROXYLOCALPATH' are set,
then this portlet translates the 'SRC' url into a reverse proxy url
by replacing the value of 'PROXYREMOTEURL' by the value of 'PROXYLOCALPATH'.
If you use the default reverse proxy component, then you should configure
the path mappings in the configuration file. (e.g., /WEB-INF/conf/reverseproxy.properties)
You can use predefined variables, ${serverName}, ${serverPort} or ${contextPath}, to set local URLs.
|
PROXYLOCALPATH | Preference | ${contextPath}/rproxy/portals/ |
The base URL of the local proxy URL.
If the value of 'PROXYLOCALPATH' doesn't starts with '/', then
this portlet prepends the context path of the local servlet application.
By default, this web application contains reverse proxy servlet mapped by '/rproxy' path.
For some cases, you can use other external proxy server by setting a context relative path
or absolute url such as '/apache' or 'http://www.localhost.com/apache'.
If you use the default reverse proxy component, then you should configure
the path mappings in the configuration file. (e.g., /WEB-INF/conf/reverseproxy.properties)
You can use the predefined variable, ${contextPath}, to set local paths.
|
AUTORESIZE | Preference | true | If this preference value is set to true, then this portlet tries to resize the height of the IFRAME tag based on the rendered content. However, this option is applied only when the 'SRC' url is in the same domain of the portal URL. Also, if 'PROXYREMOTEURL' and 'PROXYLOCALPATH' are set to use a proxy url in the same domain, then this option can be applied as well. |
VISITLASTPAGE | Preference | true | If this preference value is set to true, then this last visited page in this portlet is stored in the session and the page will be revisited when the portlet is rendered again. However, this option is applied only when the 'SRC' url is in the same domain of the portal URL. Also, if 'PROXYREMOTEURL' and 'PROXYLOCALPATH' are set to use a proxy url in the same domain, then this option can be applied as well. |
HEIGHT | Preference | 300 | The height of the IFrame window when in Normal Window State |
WIDTH | Preference | 100% | The width of the IFrame window when in Normal Window State. Can be a percentage of available space to the portlet, or a constant value |
MAX-HEIGHT | Preference | 800 | The height of the IFrame window when in Maximized Window State |
MAX-WIDTH | Preference | 100% | The width of the IFrame window when in Maximized Window State. Can be a percentage of available space to the portlet, or a constant value |
SCROLLING | Preference | AUTO | YES | NO | Specifies whether or not to display scrollbars in an iframe |
Name | Type | Example Value | Description |
---|---|---|---|
remote.uri | Preference, Request Parameter or Init Parameter | http://portals.apache.org/news.html | The remote URL to be served through the internal reverse proxy components. |
xpath.expression | Init Parameter | //div[@id='bodyColumn'] | The XPath expression string which is used by the internal reverse proxy components (using HtmlCleaner library) after retrieving the remote content in order to extract only the portion filtered by this XPath expression. |
html.cleaner.transformation | Init Parameter |
cfoutput | c:block=div,false | font=span,true | font.size | font.face | font.style=${style};font-family=${face};font-size=${size}; |
HtmlCleaner transformation setting configurations,
separated by '|'.
For detail, see http://htmlcleaner.sourceforge.net/parameters.php. |
Here are examples of the Web Content, IFrame, ReverseProxyIFrame and SimpleReverseProxy Portlets: