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:dk.netarkivet.harvester.webinterface.TrapAction.java

/**
 * This method processes the request to determine which action it corresponds to and passes the request along
 * accordingly. If it is a multipart post then it is passed along to a create-or-update instance. Otherwise if no
 * action is specified, none is taken. Otherwise the request is passed on to a specific concrete instance of this
 * class for further processing.//from  w ww  .  ja  v a  2 s .  c o  m
 *
 * @param context the original servlet context of the request.
 * @param i18n the internationalisation to be used.
 * @throws ForwardedToErrorPage if an exception is thrown while carrying out the action.
 */
public static void processRequest(PageContext context, I18n i18n) throws ForwardedToErrorPage {
    ArgumentNotValid.checkNotNull(context, "PageContext context");
    ArgumentNotValid.checkNotNull(i18n, "I18n i18n");
    log.debug("Processing request");
    HttpServletRequest request = (HttpServletRequest) context.getRequest();

    try {
        if (ServletFileUpload.isMultipartContent(request)) {
            TrapActionEnum.CREATE_OR_UPDATE.getTrapAction().doAction(context, i18n);
        } else {
            String requestType = request.getParameter(Constants.TRAP_ACTION);
            if (requestType == null || requestType.isEmpty()) {
                TrapActionEnum.NULL_ACTION.getTrapAction().doAction(context, i18n);
            } else {
                TrapActionEnum actionType = TrapActionEnum.valueOf(requestType);
                actionType.getTrapAction().doAction(context, i18n);
            }
        }
    } catch (Throwable e) {
        log.warn("Error in Global Crawler Traps", e);
        HTMLUtils.forwardWithErrorMessage(context, i18n, e, "errormsg;crawlertrap.action.error");
        throw new ForwardedToErrorPage("Error in Global Crawler Traps", e);
    }
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.ViewCourseInquiryPublicResults.java

public static ActionForward getCourseResultsActionForward(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) {
    String executionCourseId = request.getParameter("executionCourseOID");
    if (executionCourseId == null) {
        executionCourseId = request.getParameter("executionCourseID");
    }//from   w  w  w.  j a v a  2  s  .  c  o m
    ExecutionCourse executionCourse = FenixFramework.getDomainObject(executionCourseId);
    ExecutionSemester executionPeriod = executionCourse.getExecutionPeriod();

    CurricularCourseInquiryTemplate curricularCourseInquiryTemplate = CurricularCourseInquiryTemplate
            .getTemplateByExecutionPeriod(executionPeriod);
    if (curricularCourseInquiryTemplate == null) {
        request.setAttribute("notAvailableMessage", "message.inquiries.publicResults.notAvailable.m1");
        return mapping.findForward("execution-course-student-inquiries-result-notAvailable");
    }

    DegreeCurricularPlan dcp = FenixFramework.getDomainObject(request.getParameter("degreeCurricularPlanOID"));
    ExecutionDegree executionDegree = dcp
            .getExecutionDegreeByAcademicInterval(executionPeriod.getAcademicInterval());
    List<InquiryResult> results = executionCourse
            .getInquiryResultsByExecutionDegreeAndForTeachers(executionDegree);
    boolean hasNotRelevantData = executionCourse.hasNotRelevantDataFor(executionDegree);

    ResultsInquiryTemplate resultsInquiryTemplate = ResultsInquiryTemplate
            .getTemplateByExecutionPeriod(executionPeriod);
    Collection<InquiryBlock> resultBlocks = resultsInquiryTemplate.getInquiryBlocksSet();

    GroupResultsSummaryBean ucGroupResultsSummaryBean = getGeneralResults(results, resultBlocks,
            GroupResultType.COURSE_RESULTS);
    GroupResultsSummaryBean answersResultsSummaryBean = getGeneralResults(results, resultBlocks,
            GroupResultType.COURSE_ANSWERS);
    GroupResultsSummaryBean nonAnswersResultsSummaryBean = getGeneralResults(results, resultBlocks,
            GroupResultType.COURSE_NON_ANSWERS);
    if (executionCourse.getAvailableForInquiries()) {
        Collections.sort(nonAnswersResultsSummaryBean.getQuestionsResults(),
                new BeanComparator("questionResult.value"));
        Collections.reverse(nonAnswersResultsSummaryBean.getQuestionsResults());
    }

    CurricularCourse curricularCourse = executionCourse.getCurricularCourseFor(dcp);
    Double ects = curricularCourse.getEctsCredits(executionPeriod);
    Double contactLoadEcts = curricularCourse.getContactLoad() / 28;
    Double autonumousWorkEcts = ects - contactLoadEcts;

    GroupResultsSummaryBean workLoadSummaryBean = getGeneralResults(results, resultBlocks,
            GroupResultType.WORKLOAD);
    request.setAttribute("contactLoadEcts", contactLoadEcts);
    request.setAttribute("autonumousWorkEcts", autonumousWorkEcts);
    GroupResultsSummaryBean ucGeneralDataSummaryBean = getGeneralResults(results, resultBlocks,
            GroupResultType.COURSE_GENERAL_DATA);
    GroupResultsSummaryBean ucEvaluationsGroupBean = getGeneralResults(results, resultBlocks,
            GroupResultType.COURSE_EVALUATIONS);
    InquiryQuestion estimatedEvaluationQuestion = getEstimatedEvaluationsQuestion(
            curricularCourseInquiryTemplate.getInquiryBlocksSet());
    QuestionResultsSummaryBean estimatedEvaluationBeanQuestion = new QuestionResultsSummaryBean(
            estimatedEvaluationQuestion, getResultsForQuestion(results, estimatedEvaluationQuestion), null,
            null);

    InquiryQuestion totalAnswersQuestion = getInquiryQuestion(results, InquiryResultType.COURSE_TOTAL_ANSWERS);
    request.setAttribute("totalAnswers", new QuestionResultsSummaryBean(totalAnswersQuestion,
            getResultsForQuestion(results, totalAnswersQuestion).iterator().next()));

    List<TeacherShiftTypeGeneralResultBean> teachersSummaryBeans = getTeachersShiftsResults(executionCourse);
    Collections.sort(teachersSummaryBeans, new BeanComparator("professorship.person.name"));
    Collections.sort(teachersSummaryBeans, new BeanComparator("shiftType"));

    ResultClassification auditResult = getAuditResult(results);
    if (auditResult != null) {
        request.setAttribute("auditResult", auditResult.name());
    }

    request.setAttribute("ucGroupResultsSummaryBean", ucGroupResultsSummaryBean);
    request.setAttribute("answersResultsSummaryBean", answersResultsSummaryBean);
    request.setAttribute("nonAnswersResultsSummaryBean", nonAnswersResultsSummaryBean);
    request.setAttribute("workLoadSummaryBean", workLoadSummaryBean);
    request.setAttribute("ucGeneralDataSummaryBean", ucGeneralDataSummaryBean);
    request.setAttribute("ucEvaluationsGroupBean", ucEvaluationsGroupBean);
    request.setAttribute("estimatedEvaluationBeanQuestion", estimatedEvaluationBeanQuestion);
    request.setAttribute("teachersSummaryBeans", teachersSummaryBeans);

    CurricularCourseInquiryTemplate courseInquiryTemplate = CurricularCourseInquiryTemplate
            .getTemplateByExecutionPeriod(executionPeriod);
    List<BlockResultsSummaryBean> blockResultsSummaryBeans = new ArrayList<BlockResultsSummaryBean>();

    for (InquiryBlock inquiryBlock : courseInquiryTemplate.getInquiryBlocksSet()) {
        blockResultsSummaryBeans.add(new BlockResultsSummaryBean(inquiryBlock, results, null, null));
    }
    Collections.sort(blockResultsSummaryBeans, new BeanComparator("inquiryBlock.blockOrder"));

    request.setAttribute("hasNotRelevantData", hasNotRelevantData);
    request.setAttribute("executionCourse", executionCourse);
    request.setAttribute("executionPeriod", executionPeriod);
    request.setAttribute("executionDegree", executionDegree);
    request.setAttribute("resultsDate", results.iterator().next().getResultDate());
    request.setAttribute("blockResultsSummaryBeans", blockResultsSummaryBeans);

    request.setAttribute("publicContext", true);
    return new ActionForward(null, "/inquiries/showCourseInquiryResult_v3.jsp", false, "/teacher");
}

From source file:com.mobileman.projecth.web.util.UserUtils.java

public static boolean changeAutologin(User user, HttpServletRequest request, HttpServletResponse response) {
    boolean autoLogin = false;
    PersistentCookieHelper cookie = new PersistentCookieHelper();
    if (request.getParameter("staylogged") != null) {
        cookie.setUser(response, user);//from   www  . j a v  a  2 s.  c  o  m
        autoLogin = true;
    } else {
        cookie.removeUser(request, response);
    }
    return autoLogin;
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CUDEventos.java

protected static void crearConvocatoria(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlAdmin.crearConvocatoria(request.getParameter("1"), // nombre
            request.getParameter("2"), // descripcin
            request.getParameter("4"), // fin
            Integer.parseInt(request.getParameter("6")) // cupos
    );/*from w  ww  .j  a  v  a2  s .co m*/

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);
    } else
        Util.errordeRespuesta(r, out);
}

From source file:com.cubeia.backoffice.report.RequestBean.java

public static RequestBean parse(HttpServletRequest req) {
    /*/*from  w  w w .j av  a2  s .  c o m*/
     * Trim the path (which becomes the report name)
     */
    String path = trim(req.getPathInfo());
    /*
     * check the format and do default if needed
     */
    String form = req.getParameter("format");
    if (form == null) {
        form = Format.CSV.name();
    }
    /*
     * Convert parameter map to a simple string-string map
     */
    @SuppressWarnings("rawtypes")
    Map params = req.getParameterMap();
    Map<String, String> tmp = new HashMap<String, String>(params.size());
    for (Object key : params.keySet()) {
        tmp.put(key.toString(), req.getParameter(key.toString()));
    }
    /*
     * Continue parsing
     */
    return parse(path, tmp, form);
}

From source file:gov.nih.nci.cabig.caaers.web.utils.WebUtils.java

/**
 * Returns the previous page, based on the request parameter _page
 * @param request//from ww w.  j a  va 2 s.  c  om
 * @return
 */
public static int getPreviousPage(HttpServletRequest request) {
    String pg = request.getParameter("_page");
    if (StringUtils.isEmpty(pg))
        return -1;
    return Integer.parseInt(pg);
}

From source file:Model.Picture.java

public static String assign_right_left(HttpServletRequest request) {
    String pictureName = request.getParameter("file");
    String side = request.getParameter("side");

    if (side != null) {
        if (side.equals("left"))
            assignSide(pictureName, LEFT);
        else if (side.equals("right"))
            assignSide(pictureName, RIGHT);
        else if (side.equals("delete"))
            assignSide(pictureName, DONT_SHOW);
    }//ww w  . ja v  a  2 s  .  c o m

    return Tools.escapePlus(request.getParameter("nextFile"));
}

From source file:com.qatickets.common.HttpUtils.java

public static Map<String, String> extractParameters(HttpServletRequest req) {
    final Map<String, String> params = new HashMap<String, String>();
    final Enumeration enames = req.getParameterNames();
    while (enames.hasMoreElements()) {
        final String name = (String) enames.nextElement();
        final String value = req.getParameter(name);
        params.put(name, value);// w  w  w  .  ja v  a  2  s .  c  o  m
    }
    return params;

}

From source file:architecture.ee.web.util.ParamUtils.java

public static String getParameter(HttpServletRequest request, String name, String defaultValue,
        boolean emptyStringsOK) {
    String temp = request.getParameter(name);
    if (temp != null) {
        if (temp.equals("") && !emptyStringsOK)
            return defaultValue;
        else// w w  w  .  j a va2  s  .  c om
            return temp;
    } else {
        return defaultValue;
    }
}

From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Admin.CUDEventos.java

protected static void eliminarTaller(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    ArrayList r = CtrlAdmin.eliminarTaller(Integer.parseInt(request.getParameter("1"))); // id

    response.setContentType("application/json;charset=UTF-8");
    PrintWriter out = response.getWriter();
    if (r.get(0) == "error") {
        JSONObject obj = new JSONObject();
        obj.put("isError", true);
        obj.put("errorDescrip", r.get(1));
        out.print(obj);//from   www.j a  va  2s . c  o  m
    } else if (r.get(0) == "isExitoso") {
        JSONObject obj = new JSONObject();
        obj.put("Exitoso", true);
        out.print(obj);
    } else
        Util.errordeRespuesta(r, out);
}