001package org.javasimon.console.action; 002 003import org.javasimon.console.Action; 004import org.javasimon.console.ActionContext; 005import org.javasimon.console.ActionException; 006 007import java.io.IOException; 008 009import javax.servlet.ServletException; 010 011/** 012 * Action to send a redirect instruction to the browser. 013 * 014 * @author gquintana 015 */ 016public class RedirectAction extends Action { 017 018 /** Target URL. */ 019 private String target; 020 021 public RedirectAction(ActionContext context) { 022 super(context); 023 } 024 025 public RedirectAction(String target, ActionContext context) { 026 super(context); 027 this.target = target; 028 } 029 030 public String getTarget() { 031 return target; 032 } 033 034 public void setTarget(String target) { 035 this.target = target; 036 } 037 038 @Override 039 public void execute() throws ServletException, IOException, ActionException { 040 getContext().getResponse().sendRedirect(target); 041 } 042}