Example usage for javax.servlet.http HttpServletRequest getHeader

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

Introduction

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

Prototype

public String getHeader(String name);

Source Link

Document

Returns the value of the specified request header as a String.

Usage

From source file:com.dub.skoolie.web.controller.system.schedule.SystemSchoolYearController.java

@RequestMapping(value = "/system/schedule/schoolyear", method = RequestMethod.POST)
public ModelAndView editSchoolYear(@Valid SchoolYearBean schoolYearBean, BindingResult result, Model model,
        HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/schedule/schoolyear")) {
            return new ModelAndView("redirect:" + referrer);
        }//  w w  w .  j a  v a 2 s  .  c  o  m
        model.addAttribute("schoolYearBeans", uiSchoolYearServiceImpl.getSchoolYears());
        model.addAttribute("schoolYearBean", schoolYearBean);
        model.addAttribute("allSchools", uiSchoolYearServiceImpl.getAllSchools());
        return new ModelAndView("system/schedule/schoolyear");
    }
    uiSchoolYearServiceImpl.addSchoolYear(schoolYearBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:com.dub.skoolie.web.controller.system.schedule.SystemClassTimeBlockController.java

@RequestMapping(value = "/system/schedule/classtimeblock", method = RequestMethod.POST)
public ModelAndView addClassTimeBlock(@Valid ClassTimeBlockBean classTimeBlockBean, BindingResult result,
        Model model, HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/schedule/classtimeblock")) {
            return new ModelAndView("redirect:" + referrer);
        }//from w  ww  . ja v  a  2s  .  com
        model.addAttribute("classTimeBlockBeans", uiClassTimeBlockServiceImpl.getClassTimeBlocks());
        model.addAttribute("classTimeBlockBean", classTimeBlockBean);
        model.addAttribute("gradingPeriods", uiClassTimeBlockServiceImpl.getGradingPeriods());
        return new ModelAndView("system/schedule/classtimeblock");
    }
    uiClassTimeBlockServiceImpl.addClassTimeBlock(classTimeBlockBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:com.dub.skoolie.web.controller.system.school.rooms.SystemSchoolRoomController.java

@RequestMapping(value = "/system/schools/{id}/rooms/delete", method = RequestMethod.POST)
public ModelAndView deleteSchoolRoom(@PathVariable("id") Long schoolid, @RequestParam("roomid") String roomid,
        HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    uiSchoolRoomServiceImpl.deleteSchoolRoom(Long.parseLong(roomid));
    return new ModelAndView("redirect:" + referrer);
}

From source file:com.dub.skoolie.web.controller.system.school.SystemSchoolController.java

@RequestMapping(value = "/system/schools", method = RequestMethod.POST)
public ModelAndView addSchool(@Valid SchoolBean schoolBean, BindingResult result, Model model,
        HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/schools")) {
            return new ModelAndView("redirect:" + referrer);
        }//  w ww.  ja  v  a  2 s. c  o m
        model.addAttribute("schoolBean", schoolBean);
        model.addAttribute("schools", uiSchoolServiceImpl.getSchools());
        return new ModelAndView("system/school/schools");
    }
    uiSchoolServiceImpl.addSchool(schoolBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:com.sg.rest.security.components.WebTokenProcessingFilter.java

private String extractAuthTokenFromRequest(HttpServletRequest httpRequest) {
    return httpRequest.getHeader(HttpCustomHeaders.AUTH_TOKEN_HEADER.getHeader());
}

From source file:com.thoughtworks.go.server.newsecurity.filters.DenyIfRefererIsNotFilesFilter.java

private boolean isRequestFromArtifact(HttpServletRequest request) {
    final String referer = request.getHeader("Referer");
    try {/*from w  w  w  . j  a va2  s.  co m*/
        return isNotBlank(referer) && new URI(referer).getPath().startsWith("/go/files/");
    } catch (URISyntaxException e) {
        return false;
    }
}

From source file:code.tianmao.h5.controller.BackendExceptionController.java

private boolean noNeedWrapper(HttpServletRequest request) {
    String xmlHttpRequest = request.getHeader("X-Requested-With");
    String noWrapperParameter = StringUtils.defaultString(request.getParameter("noSiteMeshWapper"));
    return "XMLHttpRequest".equalsIgnoreCase(xmlHttpRequest) || noWrapperParameter.equalsIgnoreCase("true")
            || noWrapperParameter.equalsIgnoreCase("yes") || noWrapperParameter.equals("1");
}

From source file:org.impalaframework.extension.mvc.annotation.resolver.RequestHeaderArgumentResolver.java

protected Object getValue(NativeWebRequest webRequest, String headerName) {
    Object nativeRequest = webRequest.getNativeRequest();
    if (nativeRequest instanceof HttpServletRequest) {
        HttpServletRequest req = (HttpServletRequest) nativeRequest;
        return req.getHeader(headerName);
    }// w w  w.  jav  a2s  .c om
    return null;
}

From source file:com.dub.skoolie.web.controller.system.schedule.events.SystemSchoolEventController.java

@RequestMapping(value = "/system/schedule/events/school", method = RequestMethod.POST)
public ModelAndView addSchoolEvent(@Valid SchoolEventBean schoolEventBean, BindingResult result, Model model,
        HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        for (ObjectError err : result.getAllErrors()) {
            System.out.println(err.getDefaultMessage());
        }/*from   ww w.ja  va2 s .c o m*/
        if (!referrer.equals("/system/schedule/events/school")) {
            return new ModelAndView("redirect:" + referrer);
        }
        return new ModelAndView("system/schedule/events/index");
    }
    uiSchoolEventServiceImpl.addSchoolEvent(schoolEventBean);
    return new ModelAndView("system/schedule/events/index");
}

From source file:com.seyren.core.security.AuthenticationTokenFilter.java

private String extractAuthTokenFromRequest(HttpServletRequest httpRequest) {
    return httpRequest.getHeader("X-Auth-Token");
}