Example usage for javax.servlet.http HttpServletRequest setAttribute

List of usage examples for javax.servlet.http HttpServletRequest setAttribute

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest setAttribute.

Prototype

public void setAttribute(String name, Object o);

Source Link

Document

Stores an attribute in this request.

Usage

From source file:com.redhat.rhn.frontend.action.channel.manage.repo.RepoDetailsAction.java

/**
 * Method to bind the repo to a request//  ww  w  .  j  a  va2  s .  c o  m
 * @param request the servlet request
 * @param repo content source
 */
public static void bindRepo(HttpServletRequest request, ContentSource repo) {
    request.setAttribute(REPO, repo);
}

From source file:de.ifgi.fmt.web.filter.auth.Authorization.java

/**
 * /*  ww w  . j a  v a2s . c  om*/
 * @param cr
 * @param sr
 */
public static void deauth(ContainerRequest cr, HttpServletRequest sr) {
    if (sr != null) {
        sr.removeAttribute(USER_SESSION_ATTRIBUTE);
        sr.setAttribute(REMOVE_COOKIE_SESSION_ATTRIBUTE, new Boolean(true));
    }
    if (cr != null) {
        cr.setSecurityContext(new FmtSecurityContext(null));
    }
}

From source file:com.alkacon.opencms.v8.documentcenter.CmsShowDocumentCenter.java

/**
 * Sets the request attributes to make the document center work
 * //from w ww.jav a  2s.  co  m
 * @param startPath the start path of the document center
 * @param inDocPath the relative path to the current document or folder
 * @param req the current request
 * 
 * @return the absolute VFS path to the document center folder or file to show
 */
public static String setDocumentCenterAttributes(String startPath, String inDocPath, HttpServletRequest req) {

    startPath = CmsFileUtil.removeTrailingSeparator(startPath);
    // set document center start path
    req.setAttribute(CmsDocumentFrontend.ATTR_STARTPATH, startPath);
    // set relative path to document folder
    req.setAttribute(CmsDocumentFrontend.ATTR_PATHPART, inDocPath);
    // set full VFS path to document folder
    String docPath = startPath + inDocPath;
    req.setAttribute(CmsDocumentFrontend.ATTR_FULLPATH, docPath);
    return docPath;
}

From source file:fll.web.UploadProcessor.java

/**
 * Processes <code>request</code> as a file upload and puts the results back
 * in the <code>request</code> object. Each parameter that is a file upload
 * has a value of type {@link FileItem}. Other parameters have values of type
 * {@link String}./*from ww w  . ja  va2s.c  o  m*/
 * 
 * @param request
 */
public static void processUpload(final HttpServletRequest request) throws FileUploadException {
    // Parse the request
    final List<?> items = UPLOAD.parseRequest(request);
    final Iterator<?> iter = items.iterator();
    while (iter.hasNext()) {
        final FileItem item = (FileItem) iter.next();
        if (item.isFormField()) {
            request.setAttribute(item.getFieldName(), item.getString());
        } else {
            request.setAttribute(item.getFieldName(), item);
        }
    }
}

From source file:com.jsmartframework.web.manager.TagEncrypter.java

private static Cipher getEncryptCipher(HttpServletRequest request) throws Exception {
    Cipher encryptCipher = (Cipher) request.getAttribute(REQUEST_TAG_ENCRYPT_CIPHER);
    if (encryptCipher == null) {
        encryptCipher = Cipher.getInstance("AES");
        encryptCipher.init(Cipher.ENCRYPT_MODE, secretKey);
        request.setAttribute(REQUEST_TAG_ENCRYPT_CIPHER, encryptCipher);
    }//from w w w .  j  a  v  a2  s  .  co  m
    return encryptCipher;
}

From source file:com.jsmartframework.web.manager.TagEncrypter.java

private static Cipher getDecryptCipher(HttpServletRequest request) throws Exception {
    Cipher decryptCipher = (Cipher) request.getAttribute(REQUEST_TAG_DECRYPT_CIPHER);
    if (decryptCipher == null) {
        decryptCipher = Cipher.getInstance("AES");
        decryptCipher.init(Cipher.DECRYPT_MODE, secretKey);
        request.setAttribute(REQUEST_TAG_DECRYPT_CIPHER, decryptCipher);
    }/*from  ww  w .j a va2  s. c  o  m*/
    return decryptCipher;
}

From source file:module.mission.presentationTier.action.SearchMissionsAction.java

private static Collection<Mission> doPagination(final HttpServletRequest request,
        Collection<Mission> allResults) {
    final CollectionPager<Mission> pager = new CollectionPager<Mission>(allResults, RESULTS_PER_PAGE);
    request.setAttribute("collectionPager", pager);
    request.setAttribute("numberOfPages", Integer.valueOf(pager.getNumberOfPages()));
    final String pageParameter = request.getParameter("pageNumber");
    final Integer page = StringUtils.isEmpty(pageParameter) ? Integer.valueOf(1)
            : Integer.valueOf(pageParameter);
    request.setAttribute("pageNumber", page);
    return pager.getPage(page);
}

From source file:com.boylesoftware.web.Router.java

/**
 * Set authenticated user in the request.
 *
 * @param request The request./*w  w w. j  a  va 2  s.  com*/
 * @param authedUser The user, or {@code null} if the request is
 * unauthenticated.
 */
static void setAuthenticatedUser(final HttpServletRequest request, final Object authedUser) {

    request.setAttribute(AUTHED_USER_ATTNAME, (authedUser != null ? authedUser : ANONYMOUS_USER));
}

From source file:com.jdon.strutsutil.FormBeanUtil.java

/**
 * ActionForm?struts_config.xmlattribute
 * /*  w w  w. j  ava  2 s.c o  m*/
 * @param form
 * @param mapping
 * @param request
 */
public static void saveActionForm(ActionForm form, ActionMapping mapping, HttpServletRequest request) {
    if ((form != null) && (mapping.getAttribute() != null)) {
        if ("request".equals(mapping.getScope())) {
            request.setAttribute(mapping.getAttribute(), form);
        } else {
            HttpSession session = request.getSession();
            session.setAttribute(mapping.getAttribute(), form);
            request.setAttribute(mapping.getAttribute(), form);
        }
    }
}

From source file:edu.du.penrose.systems.fedoraApp.web.bus.GetFedorObjFormController.java

/**
 * Get a fedora object from the fedora server.
 * // w w  w.  jav  a  2  s. c o  m
 * TBD Is this the best place for this?
 * 
 * @param request OPTIONAL HTTP request object  used to save results for jsp
 * pages. Set to null if there is no request object.
 * @param apia
 * @param objectPID
 * @return The result fedora object fields.
 * @throws Exception 
 */
static public ObjectFields getFedoraObj(HttpServletRequest request, FedoraAPIA apia, String objectPID)
        throws Exception {

    ObjectFields results = Util.getObjectFields(apia, objectPID,
            new String[] { "pid", "state", "label", "cModel", "cDate", "mDate", "ownerId", "fType" });

    if (request != null) {
        request.setAttribute("fedora.server.types.gen.ObjectFields", results);
    }

    return results;

}