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:org.kordamp.javatrove.todo02.servlet.AbstractRoute.java

private boolean shouldReturnHtml(HttpServletRequest request) {
    String accept = request.getHeader("Accept");
    return accept != null && accept.contains("text/html");
}

From source file:com.dub.skoolie.web.controller.system.courses.SystemSubjectController.java

@RequestMapping(value = "/system/subjects", method = RequestMethod.POST)
public ModelAndView addDistrictAdmin(@Valid SubjectBean subjectBean, BindingResult result, Model model,
        HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/subjects")) {
            return new ModelAndView("redirect:" + referrer);
        }/*www .  j  a va  2  s  .  c  o  m*/
    }
    uiSubjectServiceImpl.addSubject(subjectBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:com.dub.skoolie.web.controller.system.people.faculty.SystemDistrictAdminController.java

@RequestMapping(value = "/system/people/faculty/districtadmin", method = RequestMethod.POST)
public ModelAndView addDistrictAdmin(@Valid DistrictAdminBean districtAdminBean, BindingResult result,
        Model model, HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/people/faculty/districtadmin")) {
            return new ModelAndView("redirect:" + referrer);
        }/*  w w w  .j av a 2 s  . co m*/
    }
    uiDistrictAdminServiceImpl.addDistrictAdmin(districtAdminBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:com.dub.skoolie.web.controller.system.people.faculty.SystemSchoolAdminController.java

@RequestMapping(value = "/system/people/faculty/schooladmin", method = RequestMethod.POST)
public ModelAndView addSchoolAdmin(@Valid SchoolAdminBean schoolAdminBean, BindingResult result, Model model,
        HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/people/faculty/schooladmin")) {
            return new ModelAndView("redirect:" + referrer);
        }//from  ww  w. j  a  v  a2 s.  com
    }
    uiSchoolAdminServiceImpl.addSchoolAdmin(schoolAdminBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:com.dub.skoolie.web.controller.system.people.faculty.SystemTeacherController.java

@RequestMapping(value = "/system/people/faculty/teacher", method = RequestMethod.POST)
public ModelAndView addTeacher(@Valid TeacherBean teacherBean, BindingResult result, Model model,
        HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/people/faculty/teacher")) {
            return new ModelAndView("redirect:" + referrer);
        }/* w  w w  . java 2  s .c  o m*/
    }
    uiTeacherServiceImpl.addTeacher(teacherBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:com.dub.skoolie.web.controller.system.people.parents.SystemParentController.java

@RequestMapping(value = "/system/people/parents/parent", method = RequestMethod.POST)
public ModelAndView addDistrictAdmin(@Valid ParentBean parentBean, BindingResult result, Model model,
        HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/people/parents/parent")) {
            return new ModelAndView("redirect:" + referrer);
        }/*from  www  . j  av  a  2s .c  o  m*/
    }
    uiParentServiceImpl.addParent(parentBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:com.dub.skoolie.web.controller.system.people.students.SystemStudentController.java

@RequestMapping(value = "/system/people/students/student", method = RequestMethod.POST)
public ModelAndView addDistrictAdmin(@Valid StudentBean studentBean, BindingResult result, Model model,
        HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/people/students/student")) {
            return new ModelAndView("redirect:" + referrer);
        }/*  w ww  .ja  v  a2s.c om*/
    }
    uiStudentServiceImpl.addStudent(studentBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:authentication.PreAuthenticatedUserFilter.java

/** {@inheritDoc} */
@Override//  w  ww  .j  ava 2s.c o  m
protected String getPreAuthenticatedPrincipal(final HttpServletRequest request) {
    return request.getHeader(AUTHORIZATION) != null ? (String) request.getHeader(AUTHORIZATION)
            : request.getParameter(AUTHORIZATION);
}

From source file:cc.unlimitedbladeworks.web.home.module.screen.Index.java

public String getIpAddr(HttpServletRequest request) {
    String ip = request.getHeader("x-forwarded-for");
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("Proxy-Client-IP");
    }/*from   w ww .  j  a  va  2s  . co  m*/
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("WL-Proxy-Client-IP");
    }
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getRemoteAddr();
    }
    return ip;
}

From source file:com.sentinel.config.TokenAuthenticationService.java

public Authentication getAuthentication(HttpServletRequest request) {
    final String token = request.getHeader(AUTH_HEADER_NAME);
    if (token != null) {
        final User user = tokenHandler.parseUserFromToken(token);
        if (user != null) {
            return new UserAuthentication(user);
        }/*from   w w w  .  j ava2 s  . com*/
    }
    return null;
}