001package org.javasimon.console; 002 003import java.io.IOException; 004import javax.servlet.ServletException; 005 006/** 007 * Base class for actions (controller+model) 008 * 009 * @author gquintana 010 */ 011public abstract class Action { 012 013 /** 014 * Action context (request, response & more) 015 */ 016 private final ActionContext context; 017 018 public Action(ActionContext context) { 019 this.context = context; 020 } 021 022 public ActionContext getContext() { 023 return context; 024 } 025 026 /** 027 * Parse HTTP Request parameters and store them locally 028 */ 029 public void readParameters() { 030 } 031 032 /** 033 * Execute action 034 */ 035 public abstract void execute() throws ServletException, IOException, ActionException; 036 037 // mainly for IE8 038 protected void dontCache() { 039 getContext().getResponse().setHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate"); 040 getContext().getResponse().setHeader("Pragma", "no-cache"); 041 } 042}