Digital Marketing

How to redirect URL in Glassfish / Payara Java EE server

In the admin panel, navigate to :
Configuration, HTTP Service, Virtual Servers, server
Scroll to bottom of page :
Add Property
Name :
( for the name, it should be "redirect_****", ie, always start with "redirect_", and then you can append other characters)

Value :
from=/{name of webapp to redirect} url={URL to redirect traffic to}

For example :
from=/myApp url=

Click ‘Save’ button.

You can do:

from=/myApp/myPath url=


And request parameters are redirected too.

The above only redirects to a specific address, to redirect with subfolder, for example:

/myApp/myPah1 to
/myApp/myPath2 to

then use url-prefix instead:

from=/myApp url-prefix=

This redirect only works for HTTP method GET, it doesn't work for HTTP method POST.

Directly in domain.xml:

<virtual-server hosts="${com.sun.aas.hostName}" http-listeners="http-listener-1,http-listener-2" id="server" log-file="${com.sun.aas.instanceRoot}/logs/server.log" state="on">
<property name="docroot" value="${com.sun.aas.instanceRoot}/docroot"/>
<property name="accesslog" value="${com.sun.aas.instanceRoot}/logs/access"/>
<property name="sso-enabled" value="false"/>
<property name="allowLinking" value="true"/>
<property name="redirect_i" value="from=/ url="/>

For url-prefix,
<property name="redirect_i" value="from=/ url-prefix="/>

will redirect http://current-host/ to

<property name="redirect_i" value="from=/ url-prefix="/>

will correctly redirect http://current-host/ to


Popular posts from this blog

Make online money from the Internet