public static void setAttribute(Context velocityContext,
HttpServletRequest request,
ServletContext servletContext,
String name,
Object obj,
String scope) {
if (scope == null) {
scope = "page";
}
if ("page".equals(scope)) {
velocityContext.put(name, obj);
} else if ("request".equals(scope)) {
request.setAttribute(name, obj);
} else if ("session".equals(scope)) {
request.getSession().setAttribute(name, obj);
} else if ("application".equals(scope)) {
servletContext.setAttribute(name, obj);
}
}
Sets an attribute in the desired scope. |