Saturday, August 10, 2013

How to redirect in Glassfish server 3.x

 URL Redirection Within a Domain
You can use the url-prefix element of the redirect_ property to forward a URL to another URL in the same domain.
The following procedure shows how to enable visitors to a web site to type inhttp://www.mywebsite.com/myproduct1 and be redirected or forwarded tohttp://www.mywebsite.com/mywarname/products/myproduct1.jsp.
1.    Log in to the Admin Console of Sun Java System Application Server or GlassFish.
2.    In the Admin Console, expand the Configurations node.
3.    Expand the server-config node.
Ignore this step if you are running a developer domain (a domain that does not have clustering capability).
4.    Expand HTTP Service.
5.    Expand Virtual Servers.
6.    Click server.
7.    On the Edit Virtual Server page, click the Add Property button.
8.    In the Name column, type redirect_1.
9.    If you are using Application Server 9.0, type from=/<context-root>/myproduct1 url-prefix=/mywarname/mypages/products/myproduct1.jsp in the Value column.
Note - The value of the <context-root> you provide here needs to match the value of the context root specified in the web.xml or application.xml file.
If you are using Application Server 9.1, type from=/myproduct1 url-prefix=/mywarname/mypages/products/myproduct1.jsp in the Value column.


My example was redirect from /test to somesite.com/app1

<property name="redirect_1" value="from=/test url-prefix=http://somesite.com/app1"/>