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:architecture.ee.web.util.ParamUtils.java
public static long getLongAttribute(HttpServletRequest request, String name, long defaultNum) { String temp = (String) request.getAttribute(name); if (temp != null && !temp.equals("")) { long num = defaultNum; try {/* w ww .j ava2 s .com*/ num = Long.parseLong(temp.trim()); } catch (Exception ignored) { } return num; } else { return defaultNum; } }
From source file:de.ifgi.fmt.web.filter.auth.Authorization.java
/** * /*from w ww .j av a 2 s . com*/ * @param cr * @param sr * @param u */ public static void auth(ContainerRequest cr, HttpServletRequest sr, User u) { log.debug("Authorizing session for user {}", u); if (sr != null) { if (sr.getAttribute(AUTH_TYPE_SESSION_ATTRIBUTE) == null) { sr.setAttribute(AUTH_TYPE_SESSION_ATTRIBUTE, Auth.HTTP_BASIC); } sr.setAttribute(USER_SESSION_ATTRIBUTE, u); } if (cr != null) { cr.setSecurityContext(new FmtSecurityContext(u)); } }
From source file:dk.dma.msinm.user.security.SecurityServletFilter.java
/** * Returns the response status code to use for this request. * If the AUTH_ERROR_ATTR request attribute has been set then this is returned, * otherwise, the {@code defaultStatusCode is returned. * * @param defaultStatusCode the default status code to return * @param request the request/*from w ww . j av a 2 s .co m*/ * @return the status code to use */ public static int getErrorStatusCode(HttpServletRequest request, int defaultStatusCode) { if (request.getAttribute(SecurityServletFilter.AUTH_ERROR_ATTR) != null) { return (Integer) request.getAttribute(SecurityServletFilter.AUTH_ERROR_ATTR); } return defaultStatusCode; }
From source file:architecture.ee.web.util.ParamUtils.java
public static String getAttribute(HttpServletRequest request, String name, boolean emptyStringsOK) { String temp = (String) request.getAttribute(name); if (temp != null) { if (temp.equals("") && !emptyStringsOK) return null; else/* www .j a v a 2s .c o m*/ return temp; } else { return null; } }
From source file:info.magnolia.module.servletsanity.support.ServletAssert.java
private static void testAttribute(String level, HttpServletRequest request, String attribute, String expected) throws IOException { String value = (String) request.getAttribute(attribute); if (value == null && expected != null) { append(level + " Request attribute [" + attribute + "] is missing expected [" + expected + "]"); } else if (!StringUtils.equals(value, expected)) { append(level + " Request attribute [" + attribute + "] is incorrect [" + value + "] expected [" + expected + "]"); } else {// www .j a v a 2 s . co m append("PASSED Attribute [" + attribute + "] is correct [" + value + "]"); } }
From source file:io.lavagna.web.helper.UserSession.java
public static void setUser(int userId, boolean isUserAnonymous, HttpServletRequest req, HttpServletResponse resp, UserRepository userRepository) { boolean rememberMe = "true".equals(req.getParameter("rememberMe")) || "true".equals(req.getAttribute("rememberMe")); setUser(userId, isUserAnonymous, req, resp, userRepository, rememberMe); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.coordinator.SearchDegreeLogAction.java
private static String newFindDegreeCurricularPlanID(HttpServletRequest request) { String degreeCurricularPlanID = request.getParameter("degreeCurricularPlanID"); if (degreeCurricularPlanID == null) { degreeCurricularPlanID = (String) request.getAttribute("degreeCurricularPlanID"); }/*from w w w . j a v a2s. com*/ return degreeCurricularPlanID; }
From source file:org.artifactory.webapp.servlet.RequestUtils.java
public static RepoPath getRepoPath(HttpServletRequest servletRequest) { return (RepoPath) servletRequest.getAttribute(ATTR_ARTIFACTORY_REPOSITORY_PATH); }
From source file:edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils.java
/** * Gets an attribute from the request, if it is not null, and of Class String * print it to req.out, otherwise throw an exception. * * @param req/*from w w w . j av a 2 s. c om*/ * @param attribute */ public static String writeAttribute(HttpServletRequest request, String attribute) throws JspException { Object contentObj = request.getAttribute(attribute); if (contentObj == null) throw new JspException("Attribute " + attribute + " in request attributes was null."); if (!(contentObj instanceof String)) { String className = contentObj.getClass().getName(); throw new JspException("Class of " + attribute + " is " + className + ", it should be String"); } return (String) contentObj; }
From source file:edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.java
public static ModelAccess on(HttpServletRequest req) { Object o = req.getAttribute(ATTRIBUTE_NAME); if (o instanceof ModelAccess) { return (ModelAccess) o; } else {// w ww .j a v a 2s .c o m ModelAccess parent = on(req.getSession()); ModelAccess ma = new ModelAccess(Scope.REQUEST, parent); req.setAttribute(ATTRIBUTE_NAME, ma); return ma; } }