1 package org.apache.velocity.tools.view; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import javax.servlet.http.HttpServletRequest; 23 import javax.servlet.http.HttpServletResponse; 24 import javax.servlet.ServletContext; 25 import org.apache.velocity.app.VelocityEngine; 26 import org.apache.velocity.context.Context; 27 28 /** 29 * <p>This interface provides view tools in a servlet environment 30 * access to relevant context information, like servlet request, servlet 31 * context and the velocity context.</p> 32 * <p>The standard implementation is {@link ViewToolContext}.</p> 33 * 34 * @author <a href="mailto:sidler@teamup.com">Gabe Sidler</a> 35 * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a> 36 * @author Nathan Bubna 37 * @version $Id: ViewContext.java 651469 2008-04-25 00:46:13Z nbubna $ 38 */ 39 public interface ViewContext 40 { 41 /** Key used for the HTTP request object. */ 42 public static final String REQUEST = "request"; 43 44 /** Key used for the HTTP response object. */ 45 public static final String RESPONSE = "response"; 46 47 /** Key used for the HTTP session object. */ 48 public static final String SESSION = "session"; 49 50 /** Key used for the servlet context object in templates. */ 51 public static final String APPLICATION = "application"; 52 53 /** Key used for the servlet context object in tool properties. */ 54 public static final String SERVLET_CONTEXT_KEY = "servletContext"; 55 56 /** Default key used to store toolboxes in request/session/application attributes. */ 57 public static final String DEFAULT_TOOLBOX_KEY = 58 VelocityView.DEFAULT_TOOLBOX_KEY; 59 60 61 /** 62 * <p>Returns the instance of {@link HttpServletRequest} for this request.</p> 63 */ 64 public HttpServletRequest getRequest(); 65 66 67 /** 68 * <p>Returns the instance of {@link HttpServletResponse} for this request.</p> 69 */ 70 public HttpServletResponse getResponse(); 71 72 73 /** 74 * <p>Returns the instance of {@link ServletContext} for this request.</p> 75 */ 76 public ServletContext getServletContext(); 77 78 79 /** 80 * <p>Searches for the named attribute in request, session (if valid), 81 * and application scope(s) in order and returns the value associated 82 * or null.</p> 83 * 84 * @since VelocityTools 1.1 85 */ 86 public Object getAttribute(String key); 87 88 89 /** 90 * <p>Returns a reference to the current Velocity context.</p> 91 */ 92 public Context getVelocityContext(); 93 94 95 /** 96 * <p>Returns the current VelocityEngine instance.</p> 97 */ 98 public VelocityEngine getVelocityEngine(); 99 100 }