Struts2 Redirect to External URL

We want to redirect the action to another website or URL.
for that syntax is used

<result name="success" type="redirect">${url}</result>

type=”redirect” is used to redirect this action to the specified URL.
here URL is a variable in the action class with getter and setter methods.
We are getting the URL value from the JSP page to get the URL value in struts.xml we used ${url}.

First.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib  uri="/struts-tags" prefix="s" %>
        

Redirect To another Web site

        
            
            
        
    

Struts.xml

    
        
            ${url}
        
    

RedirectAction.java

package com.ebhor;

import com.opensymphony.xwork2.ActionSupport;

public class RedirectAction extends ActionSupport {
    private String url;

    public String redirect() {
        System.out.println("Redirect to "+getUrl());
        return SUCCESS;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

}

Output