Source:
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String[] path = StringUtils.split(req.getPathInfo(), '/'); String clientEndpoint = path[0]; if (path.length < 3) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid path"); return; } try { String target = StringUtils.removeStart(req.getPathInfo(), "/" + clientEndpoint); Registration registration = server.getRegistrationService().getByEndpoint(clientEndpoint); if (registration != null) { String contentFormatParam = req.getParameter(FORMAT_PARAM); ContentFormat contentFormat = contentFormatParam != null ? ContentFormat.fromName(contentFormatParam.toUpperCase()) : null; LwM2mNode node = extractLwM2mNode(target, req); WriteRequest request = new WriteRequest(Mode.REPLACE, contentFormat, target, node); WriteResponse cResponse = server.send(registration, request, TIMEOUT); processDeviceResponse(req, resp, cResponse); } else { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); resp.getWriter().format("No registered client with id '%s'", clientEndpoint).flush(); } } catch (IllegalArgumentException e) { LOG.warn("Invalid request or response", e); resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); resp.getWriter().append(e.getMessage()).flush(); } catch (ResourceAccessException e) { LOG.warn(String.format("Error accessing resource %s%s.", req.getServletPath(), req.getPathInfo()), e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); resp.getWriter().append(e.getMessage()).flush(); } catch (InterruptedException e) { LOG.warn("Thread Interrupted", e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); resp.getWriter().append(e.getMessage()).flush(); } }

Target:
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String[] path = StringUtils.split(req.getPathInfo(), '/'); String clientEndpoint = path[0]; if (path.length < 3) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid path"); return; } try { String target = StringUtils.removeStart(req.getPathInfo(), "/" + clientEndpoint); Registration registration = server.getRegistrationService().getByEndpoint(clientEndpoint); if (registration != null) { String contentFormatParam = req.getParameter(FORMAT_PARAM); ContentFormat contentFormat = contentFormatParam != null ? ContentFormat.fromName(contentFormatParam.toUpperCase()) : null; LwM2mNode node = extractLwM2mNode(target, req); WriteRequest request = new WriteRequest(Mode.REPLACE, contentFormat, target, node); WriteResponse cResponse = server.send(registration, request, TIMEOUT); processDeviceResponse(req, resp, cResponse); } else { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); resp.getWriter().format("No registered client with id '%s'", clientEndpoint).flush(); } } catch (IllegalArgumentException e) { LOG.warn("Invalid request or response", e); resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); resp.getWriter().append(e.getMessage()).flush(); } catch (ResourceAccessException | RequestRejectedException e) { LOG.warn(String.format("Error accessing resource %s%s.", req.getServletPath(), req.getPathInfo()), e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); resp.getWriter().append(e.getMessage()).flush(); } catch (InterruptedException e) { LOG.warn("Thread Interrupted", e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); resp.getWriter().append(e.getMessage()).flush(); } }