Example usage for javax.servlet.http HttpServletRequest getParameterValues

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

Introduction

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

Prototype

public String[] getParameterValues(String name);

Source Link

Document

Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.

Usage

From source file:net.sourceforge.jwebunit.tests.util.HeadersServlet.java

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.write(HtmlHelper.getStart("Received headers"));
    out.write("<h1>Received headers</h1>\n<p>Headers are:<br/>");
    /*//from  w w w.  j  a  v  a 2s .com
     * Prints headers as name=[value] separated
     * by <BR/>
     */
    java.util.Enumeration headers = request.getHeaderNames();
    for (; headers.hasMoreElements();) {
        String h = headers.nextElement().toString();
        String v = request.getHeader(h);
        out.write(h + "=[" + v);
        if (headers.hasMoreElements()) {
            out.write("]<br/>\n");
        }
    }
    out.write("]</p>\n");
    String ref = request.getHeader("Referer");
    if (ref == null) {
        if (request.getParameterValues("myReferer") != null) {
            ref = request.getParameterValues("myReferer")[0];
        }
    }
    out.write(HtmlHelper.getLinkParagraph("return", ref));
    out.write(HtmlHelper.getEnd());
}

From source file:com.virtusa.akura.student.controller.StudentTermMarkController.java

/**
 * Handle sub term wise grades.//w  ww  . j a v  a  2s.  c o  m
 * 
 * @param request - {@link HttpServletRequest}
 * @param map - {@link ModelMap}
 * @param errorMsgLoader - {@link ErrorMsgLoader}
 * @throws AkuraAppException - throw detail exception
 */
private void populateMonthlyGrades(HttpServletRequest request, ModelMap map, ErrorMsgLoader errorMsgLoader)
        throws AkuraAppException {

    String[] studentsubTermMarks = request.getParameterValues(MONTHLYMARKS);
    String[] studentSubTermMarkIDs = request.getParameterValues(SUB_TERM_MARK_ID);
    List<StudentSubTermMark> studentSubTermMarkList = new ArrayList<StudentSubTermMark>();
    Map<String, Integer> gradingmap = new HashMap<String, Integer>();
    List<Grading> gradinglist = commonService.getGradingList();
    for (Grading grade : gradinglist) {
        gradingmap.put(grade.getGradeAcronym(), grade.getGradingId());
    }

    for (int i = 0; i < studentsubTermMarks.length; i++) {
        boolean notEditedId = false;
        String gradeAcronim = studentsubTermMarks[i];
        Integer gradingId = null;
        if (gradeAcronim != "") {
            gradingId = gradingmap.get(gradeAcronim);
        } else if ("".equalsIgnoreCase(gradeAcronim)) {
            notEditedId = true;
        }
        if (AkuraConstant.ABSENT.equalsIgnoreCase(studentsubTermMarks[i])) {
            StudentSubTermMark studentSubTermMark = studentService
                    .findStudentSubTermMark(Integer.parseInt(studentSubTermMarkIDs[i]));
            studentSubTermMark.setAbsent(true);
            studentSubTermMark.seteditMarkState(true);
            studentSubTermMarkList.add(studentSubTermMark);
        } else if (gradingId != null) {
            StudentSubTermMark studentSubTermMark = studentService
                    .findStudentSubTermMark(Integer.parseInt(studentSubTermMarkIDs[i]));
            studentSubTermMark.setGradingID(gradingId);
            studentSubTermMark.setMarks(null);
            studentSubTermMark.seteditMarkState(true);
            studentSubTermMark.setAbsent(false);
            studentSubTermMarkList.add(studentSubTermMark);

        } else if (!notEditedId) {
            errorMsgLoader = new ErrorMsgLoader();
            String message = errorMsgLoader.getErrorMessage(ERROR_MSG_KEY_INVALID_GRADING_ACRONYM);
            map.addAttribute(AkuraConstant.MESSAGE, message);
        }
    }
    studentService.updateStudentSubTermMarkList(studentSubTermMarkList);
}

From source file:org.dhara.portal.web.controllers.WorkflowMonitorController.java

@RequestMapping(value = { "/admin/monitoring", "/admin/monitoring/" }, method = RequestMethod.GET)
protected String handleRequestInternal(@RequestParam(required = false) final String action,
        @RequestParam(required = false) String referringPageId, Model model, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    addNavigationMenusToModel(SELECTED_ITEM, model, referringPageId);
    String workflowName = request.getParameter("workflowId");
    List<InputHelper> inputHelperList = new ArrayList<InputHelper>();
    //Get user specified inputs from the form
    Enumeration enumeration = request.getParameterNames();
    while (enumeration.hasMoreElements()) {
        String temp = (String) enumeration.nextElement();
        if (temp.equalsIgnoreCase("workflowId"))
            ;/*from   ww w .j  a v  a 2  s .  c o  m*/
        else {
            InputHelper inputHelper = new InputHelper();
            inputHelper.setRawName(temp);
            inputHelper.setName(temp.split("/")[0]);
            inputHelper.setType(temp.split("/")[1]);
            inputHelper.setValues(request.getParameterValues(temp));
            inputHelperList.add(inputHelper);
        }
    }

    List<UserInputHelper> inputs = new ArrayList<UserInputHelper>();

    for (InputHelper in : inputHelperList) {
        UserInputHelper userInputHelper = new UserInputHelper();
        userInputHelper.setName(in.getName());
        for (int i = 0; i < in.getValues().length; i++) {
            userInputHelper.setValue(in.getValues()[i]);
        }
        inputs.add(userInputHelper);
    }

    Object[] ints = inputs.toArray();

    //Start workflow monitoring
    Runnable monitorThread = new MonitorThread(airavataClientAPIService, workflowName, ints);
    String id = ((MonitorThread) monitorThread).getExperimentId();
    PortalConfiguration.executor.execute(monitorThread);

    model.addAttribute("id", id);
    model.addAttribute("workflowId", workflowName);
    return "templates.admin.monitoring";
}

From source file:net.duckling.ddl.web.controller.team.ConfigTeamController.java

@RequestMapping(params = "func=download")
public void download(HttpServletRequest request, HttpServletResponse response,
        @RequestParam("teamCode") String teamName, @RequestParam("format") String format) {
    VWBContext context = getVWBContext(request);
    String[] tagids = request.getParameterValues("tag");
    Map<String, List<Tag>> groupTagMap = constructGroupTagMap(tagids);
    exportService.download(context, teamName, groupTagMap, response, format);
}

From source file:fr.paris.lutece.plugins.workflow.modules.assignment.web.AssignmentTaskComponent.java

/**
 * {@inheritDoc}// w w  w.  j  a  va 2  s .  co m
 */
@Override
public String doSaveConfig(HttpServletRequest request, Locale locale, ITask task) {
    String strError = null;
    String strTitle = request.getParameter(PARAMETER_TITLE);
    String strIsMultipleOwner = request.getParameter(PARAMETER_IS_MULTIPLE_OWNER);
    String strIsNotification = request.getParameter(PARAMETER_IS_NOTIFICATION);
    String strIsUseUserName = request.getParameter(PARAMETER_IS_USE_USER_NAME);
    String strMessage = request.getParameter(PARAMETER_MESSAGE);
    String strSubject = request.getParameter(PARAMETER_SUBJECT);
    String[] tabWorkgroups = request.getParameterValues(PARAMETER_WORKGROUPS);

    if ((strTitle == null) || strTitle.trim().equals(WorkflowUtils.EMPTY_STRING)) {
        strError = FIELD_TITLE;
    }

    if ((tabWorkgroups == null) || (tabWorkgroups.length == 0)) {
        strError = FIELD_WORKGROUPS;
    }

    if ((strIsNotification != null) && ((strSubject == null) || strSubject.equals(""))) {
        strError = FIELD_MAILINGLIST_SUBJECT;
    }

    if ((strIsNotification != null) && ((strMessage == null) || strMessage.equals(""))) {
        strError = FIELD_MAILINGLIST_MESSAGE;
    }

    if (strError != null) {
        Object[] tabRequiredFields = { I18nService.getLocalizedString(strError, locale) };

        return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_FIELD, tabRequiredFields,
                AdminMessage.TYPE_STOP);
    }

    TaskAssignmentConfig config = this.getTaskConfigService().findByPrimaryKey(task.getId());
    Boolean bCreate = false;

    if (config == null) {
        config = new TaskAssignmentConfig();
        config.setIdTask(task.getId());
        bCreate = true;
    }

    //add workgroups
    List<WorkgroupConfig> listWorkgroupConfig = new ArrayList<WorkgroupConfig>();
    WorkgroupConfig workgroupConfig;

    // Ignore potential null pointer : tabWorkgroups can not be null here
    for (int i = 0; i < tabWorkgroups.length; i++) {
        workgroupConfig = new WorkgroupConfig();
        workgroupConfig.setIdTask(task.getId());
        workgroupConfig.setWorkgroupKey(tabWorkgroups[i]);

        if (strIsNotification != null) {
            if (WorkflowUtils.convertStringToInt(
                    request.getParameter(PARAMETER_ID_MAILING_LIST + "_" + tabWorkgroups[i])) != -1) {
                workgroupConfig.setIdMailingList(WorkflowUtils.convertStringToInt(
                        request.getParameter(PARAMETER_ID_MAILING_LIST + "_" + tabWorkgroups[i])));
            } else {
                return AdminMessageService.getMessageUrl(request, MESSAGE_NO_MAILINGLIST_FOR_WORKGROUP,
                        AdminMessage.TYPE_STOP);
            }
        }

        listWorkgroupConfig.add(workgroupConfig);
    }

    config.setTitle(strTitle);
    config.setNotify(strIsNotification != null);
    config.setMultipleOwner(strIsMultipleOwner != null);
    config.setWorkgroups(listWorkgroupConfig);
    config.setMessage(strMessage);
    config.setSubject(strSubject);
    config.setUseUserName(strIsUseUserName != null);

    if (bCreate) {
        this.getTaskConfigService().create(config);
    } else {
        this.getTaskConfigService().update(config);
    }

    return null;
}

From source file:com.hzc.framework.ssh.controller.WebUtil.java

private static <T> T pbRecurrence(Class<T> c, String prefix) throws RuntimeException {
    try {//from   w ww. j  a  v  a 2 s.  co m
        HttpServletRequest request = ActionContext.getReq();
        T newInstance = c.newInstance();
        Field[] declaredFields = c.getDeclaredFields();
        for (Field field : declaredFields) {
            field.setAccessible(true);
            String name = field.getName();
            String key = "".equals(prefix) ? name : prefix + "." + name;
            String value = request.getParameter(key);

            Class<?> type = field.getType();
            if (type.isArray()) {//?string   file
                Class<?> componentType = type.getComponentType();
                if (componentType == String.class) {
                    String[] values = request.getParameterValues(name);
                    //                    if (null == value || "".equals(value)) continue;
                    //                    String[] split = value.split(",");
                    field.set(newInstance, values);
                } else if (componentType == File.class) {
                    ServletContext servletContext = getServletContext();
                    File file = new File(servletContext.getRealPath("upload"));
                    if (!file.exists())
                        file.mkdir();
                    MultipartRequest multi = new MultipartRequest(request, file.getAbsolutePath(),
                            1024 * 1024 * 1024, "UTF-8", new DefaultFileRenamePolicy());
                    Enumeration files = multi.getFileNames();
                    List<File> fileList = new ArrayList<File>();
                    if (files.hasMoreElements()) {
                        File f = multi.getFile((String) files.nextElement());
                        fileList.add(f);
                    }
                    field.set(newInstance, fileList.toArray(new File[] {}));
                }

            }
            // ? 
            validation(field, name, value);
            if (null == value) {
                continue;
            }
            if (type == Long.class) {
                field.set(newInstance, Long.parseLong(value));
            } else if (type == String.class) {
                field.set(newInstance, value);
            } else if (type == Byte.class) {
                field.set(newInstance, Byte.parseByte(value));
            } else if (type == Integer.class) {
                field.set(newInstance, Integer.parseInt(value));
            } else if (type == Character.class) {
                field.set(newInstance, value.charAt(0));
            } else if (type == Boolean.class) {
                field.set(newInstance, Boolean.parseBoolean(value));
            } else if (type == Double.class) {
                field.set(newInstance, Double.parseDouble(value));
            } else if (type == Float.class) {
                field.set(newInstance, Float.parseFloat(value));
            } else if (type == Date.class) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                field.set(newInstance, sdf.parse(value));
            } else { // 
                Object obj = pbRecurrence(field.getType(), name);// 
                field.set(newInstance, obj);
            }
        }
        return newInstance;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:fr.paris.lutece.plugins.stock.modules.billetterie.web.StockBilletterieReservationApp.java

/**
 * Returns xpage for confirm booking./*from   w  ww .  ja  va  2s . c om*/
 *
 * @param page xpage
 * @param request http request
 * @param locale locale
 * @return xpage
 * @throws SiteMessageException Confirm booking page cannot be shown
 */
private XPage getConfirmBooking(XPage page, HttpServletRequest request, Locale locale)
        throws SiteMessageException {
    String[] seanceIdList = request.getParameterValues(PARAMETER_SEANCE_ID);
    String[] seanceTypeNameList = request.getParameterValues(PARAMETER_SEANCE_TYPE_NAME);
    String[] numberPlacesList = request.getParameterValues(PARAMETER_NB_PLACES);
    String showId = request.getParameter(PARAMETER_SHOW_ID);

    String strPurchaseId = request.getParameter(PARAMETER_PURCHASE_ID);

    Map<String, Object> model = new HashMap<String, Object>();
    model.put(PARAMETER_SHOW_ID, showId);

    FunctionnalException fe = getErrorOnce(request);

    List<ReservationDTO> bookingList = (List<ReservationDTO>) request.getSession()
            .getAttribute(PARAMETER_BOOKING_LIST);

    String bookingCheck;
    boolean bAuthentified = false;
    UnauthentifiedPurchaserDTO purchaser = null;

    if (fe == null) {
        // If user has already a booking in waiting state, remove it
        if (bookingList != null) {
            for (ReservationDTO reservation : bookingList) {
                _purchaseSessionManager.release(request.getSession().getId(), reservation);
            }
        }

        // Set user informations
        LuteceUser user = this.getUser(request);

        // Create booking list
        boolean bPlacesInvalid = true;
        bookingList = new ArrayList<ReservationDTO>();
        // Avoid mixing purchase session (with two opened tabs for example)
        bookingCheck = UUID.randomUUID().toString();

        try {
            int i = 0;
            ReservationDTO booking;
            int nbPlaces;

            if (seanceIdList != null) {
                for (String seanceId : seanceIdList) {
                    // Check validity of parameter
                    if (StringUtils.isNumeric(numberPlacesList[i])
                            && (Integer.valueOf(numberPlacesList[i]) > 0)) {
                        bPlacesInvalid = false;

                        // Create booking object
                        nbPlaces = Integer.valueOf(numberPlacesList[i]);

                        if (nbPlaces > 0) {
                            booking = new ReservationDTO();
                            booking.getOffer().setId(Integer.valueOf(seanceId));
                            booking.getOffer().setTypeName(seanceTypeNameList[i]);
                            booking.setQuantity(nbPlaces);
                            booking.setDate(DateUtils.getCurrentDateString());
                            booking.setHeure(DateUtils.getHourFr(DateUtils.getCurrentDate()));

                            if (user != null) {
                                String strEmail = !user.getUserInfo(LuteceUser.HOME_INFO_ONLINE_EMAIL)
                                        .equals("") ? user.getUserInfo(LuteceUser.HOME_INFO_ONLINE_EMAIL)
                                                : user.getUserInfo(LuteceUser.BUSINESS_INFO_ONLINE_EMAIL);//BUSINESS_INFO_ONLINE_EMAIL
                                booking.setUserName(user.getName());
                                booking.setEmailAgent(strEmail);
                                booking.setFirstNameAgent(user.getUserInfo(LuteceUser.NAME_GIVEN));
                                booking.setNameAgent(user.getUserInfo(LuteceUser.NAME_FAMILY));

                                bAuthentified = true;

                                // Reserve tickets
                                try {
                                    _purchaseSessionManager.reserve(request.getSession().getId(), booking);
                                } catch (PurchaseUnavailable e) {
                                    throw new BusinessException(null, MESSAGE_INSUFFICIENT_PLACE_REMAINING);
                                }
                            }

                            bookingList.add(booking);
                        }
                    }

                    i++;
                }

                if (bPlacesInvalid) {
                    throw new BusinessException(null, MESSAGE_NB_PLACES_INVALID);
                }
            }

            // Save booking into session
            request.getSession().setAttribute(PARAMETER_BOOKING_LIST, bookingList);
            request.getSession().setAttribute(PARAMETER_BOOKING_CHECK, bookingCheck);
        } catch (BusinessException e) {
            String htmlError = getHtmlError(e, request);
            model.put(BilletterieConstants.ERROR, htmlError);

            UrlItem targetUrl = new UrlItem(JSP_PORTAL);
            targetUrl.addParameter(PARAMETER_PAGE, PAGE_TICKETING);
            targetUrl.addParameter(PARAMETER_ACTION, ACTION_SHOW_DETAILS);
            targetUrl.addParameter(PARAMETER_PRODUCT_ID, showId);
            SiteMessageService.setMessage(request, e.getCode(), SiteMessage.TYPE_STOP, targetUrl.getUrl());
        }
    }

    // Manage errors
    else {
        model.put(TicketsConstants.PARAMETER_ERROR, getHtmlError(fe, request));
        bookingCheck = (String) request.getSession().getAttribute(PARAMETER_BOOKING_CHECK);
        bAuthentified = StringUtils.isNotBlank(bookingList.get(0).getEmailAgent());

        // try to retrieve DTO if unauthentied user
        Object errorBean = fe.getBean();

        if (!bAuthentified && (errorBean != null) && errorBean instanceof UnauthentifiedPurchaserDTO) {
            purchaser = (UnauthentifiedPurchaserDTO) errorBean;
        }
    }

    // Generates template
    String showName = request.getParameter(PARAMETER_SHOW_NAME);

    model.put(PARAMETER_BOOKING_LIST, bookingList);
    model.put(PARAMETER_SEANCE_DATE, request.getParameter(PARAMETER_SEANCE_DATE));
    model.put(PARAMETER_SHOW_NAME, showName);
    model.put(PARAMETER_BOOKING_CHECK, bookingCheck);
    model.put(PARAMETER_AUTHENTIFIED_USER, bAuthentified);

    int timeMax = 1;

    try {
        timeMax = Integer.parseInt(PARAMETER_TIME_MAX);
    } catch (NumberFormatException e) {
        LOGGER.error("Erreur de temps maximum avant suppression de la reservation en session : " + e);
    }

    String localizedString = I18nService.getLocalizedString(
            (timeMax > 1) ? MESSAGE_CAUTION_TIME_PURCHASE_PLURAL : MESSAGE_CAUTION_TIME_PURCHASE,
            new String[] { PARAMETER_TIME_MAX }, locale);
    model.put(MARK_CAUTION_TIME_PURCHASE, localizedString);

    // Add DTO when unauthentified
    if (!bAuthentified) {
        model.put(MARK_PURCHASER, (purchaser != null) ? purchaser : new UnauthentifiedPurchaserDTO());
    }

    HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_DIR + TEMPLATE_CONFIRM_BOOKING, locale,
            model);

    page.setContent(template.getHtml());

    String pageTitle = getMessage(TITLE_CONFIRM_BOOKING, request, showName);
    page.setPathLabel(pageTitle);
    page.setTitle(pageTitle);

    return page;
}

From source file:com.virtusa.akura.student.controller.StudentTermMarkController.java

/**
 * Handle monlthy term marks./*  w w w  .jav a  2 s  .  c o m*/
 * 
 * @param request the request
 * @param map the map
 * @param errorMsgLoader the error msg loader
 * @param isMarks the is marks
 * @throws AkuraAppException the akura app exception
 */
private void handleMonlthyTermMarks(HttpServletRequest request, ModelMap map, ErrorMsgLoader errorMsgLoader,
        String isMarks) throws AkuraAppException {

    String[] studentSubTermMarks = request.getParameterValues(MONTHLYMARKS);
    String[] studentSubTermMarkIDs = request.getParameterValues(SUB_TERM_MARK_ID);
    List<StudentSubTermMark> studentSubTermMarkList = new ArrayList<StudentSubTermMark>();

    for (int i = 0; i < studentSubTermMarks.length; i++) {

        if (AkuraConstant.ABSENT.equalsIgnoreCase(studentSubTermMarks[i])) {
            StudentSubTermMark studentSubTermMark = studentService
                    .findStudentSubTermMark(Integer.parseInt(studentSubTermMarkIDs[i]));
            studentSubTermMark.setAbsent(true);
            studentSubTermMark.seteditMarkState(true);
            studentSubTermMarkList.add(studentSubTermMark);
        } else {

            if (StringUtils.isAlpha(studentSubTermMarks[i].trim())
                    && !StringUtils.isEmpty(studentSubTermMarks[i].trim())) {
                errorMsgLoader = new ErrorMsgLoader();
                String message = errorMsgLoader.getErrorMessage(ERROR_MSG_KEY_INVALID_TERM_MARK);
                map.addAttribute(AkuraConstant.MESSAGE, message);
            } else {
                float studentMonthlyMark = 0;
                if (!StringUtils.isEmpty(studentSubTermMarks[i].trim())) {
                    studentMonthlyMark = Float.parseFloat(studentSubTermMarks[i]);
                }
                StudentSubTermMark studentSubTermMark = studentService
                        .findStudentSubTermMark(Integer.parseInt(studentSubTermMarkIDs[i]));

                // retrieves the relevant student term mark object.
                StudentTermMark studentTermMark = getStudentTermMark(studentSubTermMark);

                // retrieves the maximum grade subject mark.
                float gradeSubjectMaxMark = commonService
                        .findGradeSubjectMaxMarkById(studentTermMark.getGradeSubjectId());

                if (studentMonthlyMark >= AkuraConstant.MINIMUM_MARK
                        && studentMonthlyMark <= gradeSubjectMaxMark) {

                    studentSubTermMark.setGradingID(null);

                    // calculates the marks and set.
                    studentSubTermMark.setMarks(setMark(studentMonthlyMark, gradeSubjectMaxMark));

                    studentSubTermMark.setAbsent(false);
                    if (studentMonthlyMark != AkuraConstant.MINIMUM_MARK) {
                        studentSubTermMark.seteditMarkState(true);
                    }
                    studentSubTermMarkList.add(studentSubTermMark);
                } else {
                    errorMsgLoader = new ErrorMsgLoader();
                    String message = errorMsgLoader.getErrorMessage(ERROR_MSG_KEY_INVALID_TERM_MARK);
                    map.addAttribute(AkuraConstant.MESSAGE, message);
                }

            }
        }
    }
    studentService.updateStudentSubTermMarkList(studentSubTermMarkList);

    map.addAttribute(IS_MARKS, isMarks);
}

From source file:org.esgf.legacydatacart.WgetGeneratorController.java

/** createWGET(HttpServletRequest request, HttpServletResponse response)
 * /*from   w  w  w  . ja  va  2  s . c o m*/
 * 
 * @param request passed from the doPost method
 * @param response x-sh response type 
 */
private void createWGET(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ParserConfigurationException {

    // Create the file name
    // The file name is the id of the dataset + ".sh"
    String filename = request.getParameter("id") + ".sh";

    // Get the constraints
    String constraints = request.getParameter("constraints");

    //System.out.println("constraints: " + constraints);

    // An array of file names 
    String[] files = request.getParameterValues("child_url");

    LOG.debug("filename = " + filename);
    //queryStringInfo(request);

    // create content of the wget script
    String wgetText = writeDatasetScript(constraints, files);

    // write it to the bash file
    writeBash(wgetText, filename, response);

    LOG.debug("Finishing writing wget stream");

}

From source file:com.virtusa.akura.student.controller.StudentTermMarkController.java

/**
 * Handle term wise grades.//from   w w w  . j a v a2s  . c o  m
 * 
 * @param request - {@link HttpServletRequest}
 * @param map - {@link ModelMap}
 * @param errorMsgLoader - {@link ErrorMsgLoader}
 * @throws AkuraAppException - throw detail exception
 */
private void populateTermGrades(HttpServletRequest request, ModelMap map, ErrorMsgLoader errorMsgLoader)
        throws AkuraAppException {

    String message;
    String[] studentMarks = request.getParameterValues(GRADESUBJECTMARK);
    String[] studentTermMarkIDs = request.getParameterValues(TERMMARKID);
    List<StudentTermMark> studentTermMarkList = new ArrayList<StudentTermMark>();
    try {
        for (int i = 0; i < studentMarks.length; i++) {
            if (AkuraConstant.ABSENT.equalsIgnoreCase(studentMarks[i])) {
                StudentTermMark studentTermMark = studentService
                        .findStudentTermMark(Integer.parseInt(studentTermMarkIDs[i]));
                studentTermMark.setAbsent(true);
                studentTermMark.setMarks(0);
                studentTermMark.seteditMarkState(true);
                studentTermMarkList.add(studentTermMark);
            } else if (!studentMarks[i].isEmpty()) {
                Matcher makeMatch = checkPattern(studentMarks[i]);

                if (!makeMatch.find()) {
                    map.addAttribute(AkuraConstant.MESSAGE, AkuraWebConstant.MISMATCH_ERROR_MARKS);
                } else {
                    float studentMark = Float.parseFloat(studentMarks[i]);
                    StudentTermMark studentTermMark = studentService
                            .findStudentTermMark(Integer.parseInt(studentTermMarkIDs[i]));
                    int gradeSubjectId = studentTermMark.getGradeSubjectId();
                    final float gradeSubjectMaxMark = commonService.findGradeSubjectMaxMarkById(gradeSubjectId);
                    if (studentMark >= AkuraConstant.MINIMUM_MARK && studentMark <= gradeSubjectMaxMark) {

                        studentTermMark.setAbsent(false);

                        // calculates the marks and save into the database.
                        float maxMark = setMark(studentMark, gradeSubjectMaxMark);

                        studentTermMark.setMarks(maxMark);

                        // if the mark is not the default value or updated then change the status.
                        if (studentMark != AkuraConstant.MINIMUM_MARK) {
                            studentTermMark.seteditMarkState(true);
                        }

                        studentTermMarkList.add(studentTermMark);
                    } else {
                        errorMsgLoader = new ErrorMsgLoader();
                        message = errorMsgLoader.getErrorMessage(ERROR_MSG_KEY_INVALID_TERM_MARK);
                        map.addAttribute(AkuraConstant.MESSAGE, message);
                    }
                }
            } else {
                errorMsgLoader = new ErrorMsgLoader();
                message = errorMsgLoader.getErrorMessage(ERROR_MSG_KEY_EMPTY_TERM_MARK);
                map.addAttribute(AkuraConstant.MESSAGE, message);

            }
        }
    } catch (NumberFormatException ex) {
        ErrorMsgLoader errorMsg = new ErrorMsgLoader();
        message = errorMsg.getErrorMessage(ERROR_MSG_KEY_INVALID_TERM_MARK);
        map.addAttribute(AkuraConstant.MESSAGE, message);

    }
    studentService.updateStudentSubjectList(studentTermMarkList);

    if (!studentMarks[0].isEmpty()) {
        StudentTermMark studentTermMark = studentService
                .findStudentTermMark(Integer.parseInt(studentTermMarkIDs[0]));
        StudentClassInfo studentClassinfo = studentService
                .findStudentClassInfoById(studentTermMark.getStudentClassInfoId());
        boolean markingCompleted = false;
        if (MARKING_COMPLETED.equals(request.getParameter(MARKING_COMPLETED))) {
            markingCompleted = true;
        }
        studentService.setMarkingFlag(markingCompleted,
                studentClassinfo.getClassGrade().getGrade().getGradeId(),
                studentClassinfo.getClassGrade().getClassGradeId(), studentTermMark.getTermId(),
                studentClassinfo.getYear());
    }
}