List of usage examples for javax.servlet.http HttpServletRequest getAttribute
public Object getAttribute(String name);
Object
, or null
if no attribute of the given name exists. From source file:com.activecq.api.utils.HttpRequestUtil.java
/** * Checks if the Request has non-Blank Attribute value @ key * * @param request/*w w w. j a v a 2 s .c o m*/ * @param key * @return */ public static boolean hasAttribute(HttpServletRequest request, String key) { if (request == null) { return false; } String tmp = (String) request.getAttribute(key); return StringUtils.isNotBlank(tmp); }
From source file:com.manydesigns.elements.servlet.ServletUtils.java
public static void dumpRequestAttributes(HttpServletRequest request) { Enumeration attNames = request.getAttributeNames(); while (attNames.hasMoreElements()) { String attrName = (String) attNames.nextElement(); Object attrValue = request.getAttribute(attrName); logger.info("{} = {}", attrName, attrValue); }//from ww w . ja va 2 s . c o m }
From source file:net.sourceforge.vulcan.web.struts.actions.BaseDispatchAction.java
protected final static void addMessage(HttpServletRequest request, String messagesKey, String propertyName, ActionMessage message) {/*from w ww. jav a 2 s .c om*/ ActionMessages msgs = (ActionMessages) request.getAttribute(messagesKey); if (msgs == null) { msgs = new ActionMessages(); } msgs.add(propertyName, message); request.setAttribute(messagesKey, msgs); }
From source file:architecture.ee.web.util.ParamUtils.java
public static boolean getBooleanAttribute(HttpServletRequest request, String name) { String temp = (String) request.getAttribute(name); return temp != null && temp.equals("true"); }
From source file:com.glaf.core.res.MessageUtils.java
/** * Adds the specified messages keys into the appropriate request attribute * for use by the <html:messages> tag (if messages="true" is set), if * any messages are required. Initialize the attribute if it has not already * been. Otherwise, ensure that the request attribute is not set. * /* w w w. j a va 2s . c o m*/ * @param request * The servlet request we are processing * @param messages * Messages object * @since Struts 1.2.1 */ public static void addMessages(HttpServletRequest request, ViewMessages messages) { if (messages == null) { // bad programmer! *slap* return; } // get any existing messages from the request, or make a new one ViewMessages viewMessages = (ViewMessages) request.getAttribute(Globals.MESSAGE_KEY); if (viewMessages == null) { viewMessages = new ViewMessages(); } // add incoming messages viewMessages.add(messages); // if still empty, just wipe it out from the request if (viewMessages.isEmpty()) { request.removeAttribute(Globals.MESSAGE_KEY); return; } log.debug("save viewMessages..."); // Save the messages request.setAttribute(Globals.MESSAGE_KEY, viewMessages); }
From source file:com.jdon.strutsutil.FormBeanUtil.java
/** * ?struts_config.xmlattributeActionForm? * /*from w ww. j av a 2 s . c o m*/ * @param form * @param mapping * @param request */ public static ActionForm loadActionForm(ActionMapping mapping, HttpServletRequest request) { if ("request".equals(mapping.getScope())) { return (ActionForm) request.getAttribute(mapping.getAttribute()); } else { HttpSession session = request.getSession(); return (ActionForm) session.getAttribute(mapping.getAttribute()); } }
From source file:edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils.java
public static String getCustomShortView(HttpServletRequest request) { Individual object = ((ObjectPropertyStatement) request.getAttribute("opStmt")).getObject(); return getCustomShortView(object, request); }
From source file:com.jdon.strutsutil.FormBeanUtil.java
/** * lookup ActionForm in//from w w w. j av a2 s . c o m * * @param request * @return */ public static ActionForm lookupActionForm(HttpServletRequest request, String formName) { ActionForm actionForm = null; actionForm = (ActionForm) request.getAttribute(formName); if (actionForm == null && request.getSession(false) != null) { HttpSession session = request.getSession(false); actionForm = (ActionForm) session.getAttribute(formName); } return actionForm; }
From source file:architecture.ee.web.util.ParamUtils.java
public static int getIntAttribute(HttpServletRequest request, String name, int defaultNum) { String temp = (String) request.getAttribute(name); if (temp != null && !temp.equals("")) { int num = defaultNum; try {// w w w. j a va 2s .com num = Integer.parseInt(temp.trim()); } catch (Exception ignored) { } return num; } else { return defaultNum; } }
From source file:info.magnolia.module.servletsanity.support.ServletAssert.java
private static void printAttribute(HttpServletRequest request, String attribute) throws IOException { append(" " + attribute + " = " + request.getAttribute(attribute)); }