Example usage for javax.servlet.http HttpServletRequest getParameter

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

Introduction

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

Prototype

public String getParameter(String name);

Source Link

Document

Returns the value of a request parameter as a String, or null if the parameter does not exist.

Usage

From source file:ispyb.client.common.util.FileUtil.java

public static boolean isJpgThumbForImage(Integer imageId, HttpServletRequest request) throws Exception {

    boolean isJpg = false;

    Integer proposalId = (Integer) request.getSession().getAttribute(Constants.PROPOSAL_ID);
    if (proposalId == null) {
        proposalId = new Integer(request.getParameter(Constants.PROPOSAL_ID));
    }//  ww w.  j  a v  a2s. c om

    Ejb3ServiceLocator ejb3ServiceLocator = Ejb3ServiceLocator.getInstance();
    Image3Service imageService = (Image3Service) ejb3ServiceLocator.getLocalService(Image3Service.class);
    // two variables to guarantee the user fecths only its own images
    List<Image3VO> imageFetchedList = imageService.findByImageIdAndProposalId(imageId, proposalId);

    if (imageFetchedList.size() == 1) {

        Image3VO imgValue = imageFetchedList.get(0);

        String sourceFileName = imgValue.getJpegThumbnailFileFullPath();
        sourceFileName = PathUtils.FitPathToOS(sourceFileName);

        isJpg = FileUtil.fileExists(sourceFileName);
    }

    return isJpg;

}

From source file:fr.paris.lutece.portal.web.PortalJspBean.java

/**
 * Set the upload filter site next url/*  w  w  w . j  av  a 2  s  .  c o  m*/
 * @param request the HTTP request
 */
public static void setUploadFilterSiteNextUrl(HttpServletRequest request) {
    String strNextUrl = request.getRequestURI();
    UrlItem url = new UrlItem(strNextUrl);
    Enumeration enumParams = request.getParameterNames();

    while (enumParams.hasMoreElements()) {
        String strParamName = (String) enumParams.nextElement();
        url.addParameter(strParamName, request.getParameter(strParamName));
    }

    HttpSession session = request.getSession(true);
    session.setAttribute(ATTRIBUTE_UPLOAD_FILTER_SITE_NEXT_URL, url.getUrl());
}

From source file:net.duckling.ddl.util.ResourceQuery.java

private static int getRequestRid(HttpServletRequest request) {
    String r = request.getParameter("rid");
    int rid = 0;/*from w  ww  .j av a2  s  .com*/
    if (StringUtils.isEmpty(r)) {
        String path = request.getParameter("path");
        if (!StringUtils.isEmpty(path)) {
            String[] s = path.split("/");
            try {
                rid = Integer.parseInt(s[s.length - 1]);
            } catch (Exception e) {
            }
        }
    } else {
        rid = Integer.parseInt(r);
    }
    return rid;
}

From source file:net.duckling.ddl.util.ResourceQuery.java

private static int getMaxSize(HttpServletRequest request) {
    String size = request.getParameter("maxPageSize");
    if (ALL.equals(size)) {
        return SIZE_ALL;
    }// w ww. j ava2 s . co m
    if (StringUtils.isEmpty(size)) {
        return maxPageSize;
    }
    try {
        return Integer.parseInt(size);
    } catch (Exception e) {
        return maxPageSize;
    }
}

From source file:azkaban.server.HttpRequestUtils.java

public static Map<String, String> getParamGroup(HttpServletRequest request, String groupName)
        throws ServletException {
    @SuppressWarnings("unchecked")
    Enumeration<Object> enumerate = (Enumeration<Object>) request.getParameterNames();
    String matchString = groupName + "[";

    HashMap<String, String> groupParam = new HashMap<String, String>();
    while (enumerate.hasMoreElements()) {
        String str = (String) enumerate.nextElement();
        if (str.startsWith(matchString)) {
            groupParam.put(str.substring(matchString.length(), str.length() - 1), request.getParameter(str));
        }/* ww  w.j av  a  2  s  .c  o  m*/

    }
    return groupParam;
}

From source file:com.google.sampling.experiential.server.EventServlet.java

private static String getParam(HttpServletRequest req, String paramName) {
    try {//  w  ww.j a v  a2s  .  c o  m
        String parameter = req.getParameter(paramName);
        if (parameter == null || parameter.isEmpty()) {
            return null;
        }
        return URLDecoder.decode(parameter, "UTF-8");
    } catch (UnsupportedEncodingException e1) {
        throw new IllegalArgumentException("Unspported encoding");
    }
}

From source file:fr.paris.lutece.portal.web.PortalJspBean.java

/**
 * This method is called by Portal.jsp when it caught an
 * UserNotSignedException./*  w  w  w  .j a va2s. com*/
 * It gives the login url and stores in the session the url asked
 * @param request The HTTP request
 * @return The login page URL
 * @since v1.1
 */
public static String redirectLogin(HttpServletRequest request) {
    String strNextUrl = request.getRequestURI();
    UrlItem url = new UrlItem(strNextUrl);
    Enumeration enumParams = request.getParameterNames();

    while (enumParams.hasMoreElements()) {
        String strParamName = (String) enumParams.nextElement();
        url.addParameter(strParamName, request.getParameter(strParamName));
    }

    HttpSession session = request.getSession(true);
    session.setAttribute(ATTRIBUTE_LOGIN_NEXT_URL, url.getUrl());

    String strRedirect = SecurityService.getInstance().getLoginPageUrl();

    return AppPathService.getAbsoluteUrl(request, strRedirect);
}

From source file:gr.forth.ics.isl.x3mlEditor.upload.RequestParser.java

static RequestParser getInstance(HttpServletRequest request, MultipartUploadParser multipartUploadParser)
        throws Exception {

    RequestParser requestParser = new RequestParser();

    if (multipartUploadParser != null) {
        requestParser.uploadItem = multipartUploadParser.getFirstFile();
        requestParser.filename = multipartUploadParser.getFirstFile().getName();
        //IE sends full path, so we have to strip it...
        if (requestParser.filename.contains(System.getProperty("file.separator"))) {
            requestParser.filename = requestParser.filename
                    .substring(requestParser.filename.lastIndexOf(System.getProperty("file.separator")) + 1);
        }/*w w  w .ja v a2  s . c om*/

    } else {
        requestParser.filename = request.getParameter(FILENAME_PARAM);

    }

    //grab other params here...

    return requestParser;
}

From source file:com.ofbizcn.securityext.login.LoginEvents.java

/**
 * Save USERNAME and PASSWORD for use by auth pages even if we start in non-auth pages.
 *
 * @param request The HTTP request object for the current JSP or Servlet request.
 * @param response The HTTP response object for the current JSP or Servlet request.
 * @return String/*from   w w w  . j  a  v a2  s.c  o  m*/
 */
public static String saveEntryParams(HttpServletRequest request, HttpServletResponse response) {
    GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
    HttpSession session = request.getSession();
    Delegator delegator = (Delegator) request.getAttribute("delegator");

    // save entry login parameters if we don't have a valid login object
    if (userLogin == null) {

        String username = request.getParameter("USERNAME");
        String password = request.getParameter("PASSWORD");

        if ((username != null) && ("true".equalsIgnoreCase(EntityUtilProperties
                .getPropertyValue("security.properties", "username.lowercase", delegator)))) {
            username = username.toLowerCase();
        }
        if ((password != null) && ("true".equalsIgnoreCase(EntityUtilProperties
                .getPropertyValue("security.properties", "password.lowercase", delegator)))) {
            password = password.toLowerCase();
        }

        // save parameters into the session - so they can be used later, if needed
        if (username != null)
            session.setAttribute("USERNAME", username);
        if (password != null)
            session.setAttribute("PASSWORD", password);

    } else {
        // if the login object is valid, remove attributes
        session.removeAttribute("USERNAME");
        session.removeAttribute("PASSWORD");
    }

    return "success";
}

From source file:fr.paris.lutece.portal.service.user.attribute.AdminUserFieldService.java

/**
 * Check if the user fields are correctly filled
 * @param request HttpServletRequest//from w ww.j a v a2s  .c  om
 * @param locale locale
 * @return null if there are no problem
 */
public static String checkUserFields(HttpServletRequest request, Locale locale) {
    // Specific attributes
    List<IAttribute> listAttributes = _attributeService.getAllAttributesWithoutFields(locale);

    for (IAttribute attribute : listAttributes) {
        if (attribute.isAttributeImage()) {
            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
            FileItem fileItem = multipartRequest
                    .getFile(PARAMETER_ATTRIBUTE + CONSTANT_UNDERSCORE + attribute.getIdAttribute());
            String strUpdateAttribute = request.getParameter(
                    PARAMETER_UPDATE_ATTRIBUTE + CONSTANT_UNDERSCORE + attribute.getIdAttribute());

            if (attribute.isMandatory() && (strUpdateAttribute != null)
                    && ((fileItem == null) || (fileItem.getSize() == 0))) {
                return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS,
                        AdminMessage.TYPE_STOP);
            }
        } else {
            String value = request
                    .getParameter(PARAMETER_ATTRIBUTE + CONSTANT_UNDERSCORE + attribute.getIdAttribute());

            if (attribute.isMandatory() && ((value == null) || value.equals(CONSTANT_EMPTY_STRING))) {
                return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS,
                        AdminMessage.TYPE_STOP);
            }
        }
    }

    return null;
}