/*
 * $Id: ForwardResponse.java 220 2007-07-16 10:32:15Z sugimotokenichi $
 * Copyright (C) 2006 SUGIMOTO Ken-ichi
 * 作成日: 2006/03/17
 */
package feat2.impl;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;

import feat2.CommandContext;
import feat2.Response;
import feat2.config.ForwardConfig;

/**
 * HTTPリクエストのフォワード。
 * @author SUGIMOTO Ken-ichi
 */
public class ForwardResponse implements Response {

    private ForwardConfig config;


    public ForwardResponse(ForwardConfig config) {
        this.config = config;
    }


    public String output(CommandContext ctx)
            throws IOException, ServletException {

        RequestDispatcher rd = ctx.getServletContext().getRequestDispatcher(config.getPath());
        rd.forward(ctx.getRequest(), ctx.getResponse());

        return null;

    }

}
