Example usage for javax.servlet.http HttpServletRequest getServletPath

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

Introduction

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

Prototype

public String getServletPath();

Source Link

Document

Returns the part of this request's URL that calls the servlet.

Usage

From source file:com.flipkart.phantom.runtime.impl.spring.web.HandlerConfigController.java

/**
 * Finds the jobname from the request URL
 *///from   www . ja  va  2s  . c  o m
@ModelAttribute("handlerName")
public String getJobName(HttpServletRequest request) {
    String path = request.getServletPath();
    int index = path.lastIndexOf("handler/") + 8;
    if (index >= 0) {
        path = path.substring(index);
    }
    return path;
}

From source file:com.swdouglass.joid.consumer.OpenIdFilter.java

private boolean ignored(HttpServletRequest request) {
    String servletPath = request.getServletPath();
    for (int i = 0; i < ignorePaths.size(); i++) {
        String s = ignorePaths.get(i);
        if (servletPath.startsWith(s)) {
            return true;
        }/*from   w  w w .  j a va  2  s.c  o  m*/
    }
    return false;
}

From source file:de.highbyte_le.weberknecht.request.ModelHelper.java

@Deprecated
public void setSelf(HttpServletRequest request) {
    StringBuilder b = new StringBuilder();

    b.append(request.getContextPath());//  ww w. j  a v a2 s  .co m
    b.append(request.getServletPath());

    setSelf(b.toString());
}

From source file:org.springsource.sinspctr.rest.SInspctrController.java

@ResponseBody
@RequestMapping(value = "/**/*.xml", method = RequestMethod.GET)
public ResponseEntity<String> findConfig(HttpServletRequest request) {
    ResponseEntity<String> response;
    try {//from  w w  w.  j  a  v a 2  s.  co m
        String servletPath = request.getServletPath();
        if (servletPath.startsWith("/sinspctr/configs")) {
            servletPath = servletPath.substring("/sinspctr/configs".length(), servletPath.length());
        }
        File siConfigFile = ResourceLocator.getClasspathRelativeFile(servletPath);
        HttpHeaders headers = new HttpHeaders();
        headers.add("content-type", "application/xml");
        response = new ResponseEntity<String>(FileCopyUtils.copyToString(new FileReader(siConfigFile)), headers,
                HttpStatus.OK);
        return response;
    } catch (Exception e) {
        return new ResponseEntity<String>(HttpStatus.NOT_FOUND);
    }
}

From source file:ar.com.zauber.commons.spring.web.handlers.UrlBasedHandlerAdapter.java

/**
 * @param request// w w w. j  av  a 2  s  . c  om
 * @return
 */
private HandlerAdapter getHandler(final HttpServletRequest request) {
    final String servletPath = request.getServletPath();
    for (String pattern : specialAdapters.keySet()) {
        if (pathMatcher.match(pattern, servletPath)) {
            return specialAdapters.get(pattern);
        }
    }
    return defaultAdapter;
}

From source file:it.volaconnoi.servlet.CheckInServlet.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request// w  w w.j a  va 2 s.com
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String userPath = request.getServletPath();

    if (userPath.equals("/checkin")) {
        request.getRequestDispatcher("/WEB-INF/checkin/checkin.jsp").forward(request, response);
    }

    if (userPath.equals("/CheckinConfirm")) {
        String reservId = request.getParameter("reservId");

        CheckIn ci = new CheckIn();
        ci.setId(reservId);

        checkInFacade.create(ci);
    }
}

From source file:net.oneandone.stool.overview.GoController.java

@RequestMapping(value = "/**", method = RequestMethod.GET)
public ModelAndView goToStage(HttpServletRequest httpServletRequest)
        throws IOException, SAXException, NamingException, UserNotFound, EnumerationFailed {
    String requestetStage = httpServletRequest.getServletPath().replace("/go/", "");
    String baseurl = httpServletRequest.getRequestURL().toString();
    baseurl = baseurl.substring(0, baseurl.indexOf('/', 8));

    if (!session.wrappers.join(requestetStage).exists()) {
        return new ModelAndView("redirect:" + baseurl + "/#!404:" + requestetStage);
    }/*from  w  w  w. j  a  v  a  2 s  . c o  m*/

    StageInfo stage = StageGatherer.get(requestetStage, session, users);

    switch (stage.getRunning()) {
    case "up":
        return new ModelAndView("redirect:" + stage.getUrls().values().toArray()[0]);
    default:
        return new ModelAndView("redirect:" + baseurl + "/#!500!" + stage.getName() + "!" + stage.getRunning());
    }
}

From source file:com.apress.progwt.server.web.controllers.CollegeController.java

@RequestMapping(method = RequestMethod.GET)
public String collegeHandler(HttpServletRequest req, ModelMap model) throws InfrastructureException {

    log.debug("SERVLET PATH: " + req.getServletPath() + " " + req.getPathInfo() + " " + req.getQueryString());

    String path = req.getPathInfo();
    path = path.replace('_', ' ');

    String[] pathParts = path.split("/");
    log.debug("!path parts " + Arrays.toString(pathParts));

    // "/college/dartmouth" splits to [,dartmouth]
    if (pathParts.length < 2) {
        return getNotFoundView();
    }/*w ww  . j  a  v a2 s .co  m*/

    String schoolName = pathParts[1];

    School school = schoolService.getSchoolDetails(schoolName);
    if (school == null) {
        model.addAttribute("message", "Couldn't find school " + schoolName);
        return getNotFoundView();
    }

    PostsList forumPosts = schoolService.getForum(school, 0, 10);
    ForumBootstrap forumBootstrap = new ForumBootstrap(serializer, forumPosts, school);
    model.addAttribute("forumBootstrap", forumBootstrap);

    model.addAttribute("school", school);
    model.addAttribute("interestedIn", schoolService.getUsersInterestedIn(school));

    ControllerUtil.updateModelMapWithDefaults(model, req, userService);

    return view;
}

From source file:com.swdouglass.joid.server.UserUrlFilter.java

@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain filterChain)
        throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) req;
    HttpServletResponse response = (HttpServletResponse) res;

    String s = request.getServletPath();
    s = URLDecoder.decode(s, "utf-8");
    log.debug("servletpath: " + s);
    String[] sections = s.split("/");
    log.debug("sections.length: " + sections.length);
    String contextPath = request.getContextPath();
    if (sections.length >= 2) {
        for (int i = 0; i < sections.length; i++) {
            String section = sections[i];
            log.debug("section: " + section);
            if (section.equals("user")) {
                String username = sections[i + 1];
                log.debug("username: " + username);
                log.debug("forwarding to: " + contextPath + idJsp);
                request.setAttribute("username", username);
                forward(request, response, idJsp);
                return;
            }/*from   w w w  . j  av a 2s  . c o m*/
        }

    }
    filterChain.doFilter(req, res);
}

From source file:gov.nih.nci.cabig.caaers.ws.AuditInfoPopulatorWSInterceptor.java

public void handleMessage(Message message) throws Fault {
    if (logger.isDebugEnabled())
        logger.debug("About to populate the auditing information");
    Authentication authz = SecurityUtils.getAuthentication();

    String userName = "SYSTEM";
    if (authz != null) {
        userName = SecurityUtils.getUserLoginName(authz);
    }/*from  w w w.  j a  va2 s .  c  o  m*/
    String ipAddress = "127.0.0.1";
    String url = "webservice";
    HttpServletRequest request = (HttpServletRequest) message.get("HTTP.REQUEST");
    if (request != null) {
        ipAddress = request.getRemoteAddr();
        url = request.getServletPath();
    }
    DataAuditInfo newAuditInfo = AuditUtils.generateDataAuditInfo(userName, ipAddress, url);
    DataAuditInfo existing = (DataAuditInfo) DataAuditInfo.getLocal();
    DataAuditInfo.setLocal(newAuditInfo);
    if (logger.isDebugEnabled())
        logger.debug("Associated to thread AuditInfo  " + newAuditInfo.toString());
}