org.mortbay.jetty.Request Java Examples
The following examples show how to use
org.mortbay.jetty.Request.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerView.java From blog-codes with Apache License 2.0 | 6 votes |
/** * */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String xml = URLDecoder.decode(request.getParameter("xml"), "UTF-8"); if (xml != null) { HttpSession session = request.getSession(true); try { session.setAttribute("xml", xml); response.setStatus(HttpServletResponse.SC_OK); ((Request) request).setHandled(true); } catch (Exception e) { throw new ServletException(e); } } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }
Example #2
Source File: CustomLocalServerReceiver.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch ) throws IOException, ServletException { if ( target.contains( "/Callback" ) ) { CustomLocalServerReceiver.this.error = request.getParameter( "error" ); if ( CustomLocalServerReceiver.this.code == null ) { CustomLocalServerReceiver.this.code = request.getParameter( "code" ); } if ( CustomLocalServerReceiver.this.url != null && CustomLocalServerReceiver.this.error != null && CustomLocalServerReceiver.this.error.equals( "access_denied" ) ) { response.sendRedirect( CustomLocalServerReceiver.this.url ); } else { super.handle( target, request, response, dispatch ); } ( (Request) request ).setHandled( true ); } }
Example #3
Source File: SlackNotificationTestServer.java From tcSlackBuildNotifier with MIT License | 6 votes |
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); response.setStatus(this.response); switch (this.response) { case HttpServletResponse.SC_OK: //response.getWriter().println("<h1>Hello SimpleServlet</h1>"); this.printParams(request, response); break; case HttpServletResponse.SC_MOVED_TEMPORARILY: response.sendRedirect("/200"); break; default: response.getWriter().println("<h1>Hello from defaultt</h1>"); break; } System.out.println("Handling Web request for " + ((Request) request).getUri().toString()); }
Example #4
Source File: WebServicesVersionConversionTest.java From attic-apex-core with Apache License 2.0 | 6 votes |
@Override public void handle(String target, HttpServletRequest request, HttpServletResponse response, int i) throws IOException, ServletException { logger.debug("Target: {}. Request URL: {}" + target, request.getRequestURI()); response.setContentType(MediaType.APPLICATION_JSON); JSONObject json = new JSONObject(); try { json.put("old_key", "value"); json.put("other_key", "other_value"); json.put("url", request.getRequestURI()); } catch (JSONException ex) { throw new RuntimeException(ex); } response.getWriter().println(json.toString()); response.setStatus(200); ((Request)request).setHandled(true); }
Example #5
Source File: ConsumerManagerTest.java From openid4java with Apache License 2.0 | 6 votes |
public MockOpenIDServer(int port) { super(port); this.port = port; setHandler(new AbstractHandler() { public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException { MockOpenIDServer.this.requestParams.add(request.getParameterMap()); ParameterList params = new ParameterList(); params.set(new Parameter("ns",AssociationResponse.OPENID2_NS)); params.set(new Parameter("assoc_handle",String.valueOf(System.nanoTime()))); params.set(new Parameter("assoc_type",request.getParameter("openid.assoc_type"))); params.set(new Parameter("session_type",request.getParameter("openid.session_type"))); params.set(new Parameter("expires_in","1799")); params.set(new Parameter("dh_server_public","eRm/Qn9lXQJc30ZQLtNFkrjQHuQCLyQ2fRNwLZTGVP50Lhx16EjksA6N0RvXzoJgY8/FdKioOYXKeWVvstHTUReXfF5EC9cnTVOFtTrMegJXHZIHdk+IITwsfGfTlVxMOc7DdCFOOMRWMOA9sYB5n5OoxnzYCob3vo39+Xytlcs=")); params.set(new Parameter("enc_mac_key","CY08gTx1u4XravtWT3V5Er4sG+o=")); response.getWriter().write(params.toString()); ((Request) request).setHandled(true); } }); }
Example #6
Source File: CustomLocalServerReceiver.java From hop with Apache License 2.0 | 6 votes |
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch ) throws IOException, ServletException { if ( target.contains( "/Callback" ) ) { CustomLocalServerReceiver.this.error = request.getParameter( "error" ); if ( CustomLocalServerReceiver.this.code == null ) { CustomLocalServerReceiver.this.code = request.getParameter( "code" ); } if ( CustomLocalServerReceiver.this.url != null && CustomLocalServerReceiver.this.error != null && CustomLocalServerReceiver.this.error.equals( "access_denied" ) ) { response.sendRedirect( CustomLocalServerReceiver.this.url ); } else { super.handle( target, request, response, dispatch ); } ( (Request) request ).setHandled( true ); } }
Example #7
Source File: SLSWebApp.java From hadoop with Apache License 2.0 | 5 votes |
/** * package metrics information in a json and return * @param request http request * @param response http response * @throws java.io.IOException */ private void printJsonMetrics(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/json"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println(generateRealTimeTrackingMetrics()); ((Request) request).setHandled(true); }
Example #8
Source File: GenerateToken.java From socialauth with MIT License | 5 votes |
@Override public void handle(final String target, final HttpServletRequest request, final HttpServletResponse response, final int dispatch) throws IOException { if (!callbackPath.equals(target)) { return; } writeLandingHtml(response); response.flushBuffer(); ((Request) request).setHandled(true); lock.lock(); try { error = request.getParameter("error"); if (request.getParameter("code") != null) { code = request.getParameter("code"); } else if (request.getParameter("oauth_token") != null) { code = request.getParameter("oauth_token"); } Map<String, String[]> map = request.getParameterMap(); paramsMap = new HashMap<String, String>(); for (Map.Entry<String, String[]> entry : map.entrySet()) { String key = entry.getKey(); String values[] = entry.getValue(); paramsMap.put(key, values[0].toString()); // Only 1 value is } gotAuthorizationResponse.signal(); LOG.debug("Auth code :: " + code); } finally { lock.unlock(); } }
Example #9
Source File: NotFoundHandler.java From nutch-htmlunit with Apache License 2.0 | 5 votes |
@Override public void handle(Request req, HttpServletResponse res, String target, int dispatch) throws IOException, ServletException { // don't pass it down the chain req.setHandled(true); res.addHeader("X-Handled-By", getClass().getSimpleName()); addMyHeader(res, "URI", req.getUri().toString()); res.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found: " + req.getUri().toString()); }
Example #10
Source File: AbstractTestbedHandler.java From nutch-htmlunit with Apache License 2.0 | 5 votes |
@Override public void handle(String target, HttpServletRequest req, HttpServletResponse res, int dispatch) throws IOException, ServletException { Request base_request = (req instanceof Request) ? (Request)req : HttpConnection.getCurrentConnection().getRequest(); res.addHeader("X-TestbedHandlers", this.getClass().getSimpleName()); handle(base_request, res, target, dispatch); }
Example #11
Source File: DelayHandler.java From nutch-htmlunit with Apache License 2.0 | 5 votes |
@Override public void handle(Request req, HttpServletResponse res, String target, int dispatch) throws IOException, ServletException { try { int del = random ? r.nextInt(delay) : delay; Thread.sleep(del); addMyHeader(res, "Delay", String.valueOf(del)); } catch (Exception e) { } }
Example #12
Source File: HTTPMetricsServer.java From mt-flume with Apache License 2.0 | 5 votes |
@Override public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException { // /metrics is the only place to pull metrics. //If we want to use any other url for something else, we should make sure //that for metrics only /metrics is used to prevent backward //compatibility issues. if (target.equals("/")) { response.setContentType("text/html;charset=utf-8"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().write("For Flume metrics please click" + " <a href = \"./metrics\"> here</a>."); response.flushBuffer(); ((Request) request).setHandled(true); return; } else if (target.equalsIgnoreCase("/metrics")) { response.setContentType("application/json;charset=utf-8"); response.setStatus(HttpServletResponse.SC_OK); Map<String, Map<String, String>> metricsMap = JMXPollUtil.getAllMBeans(); String json = gson.toJson(metricsMap, mapType); response.getWriter().write(json); response.flushBuffer(); ((Request) request).setHandled(true); return; } response.sendError(HttpServletResponse.SC_NOT_FOUND); response.flushBuffer(); //Not handling the request returns a Not found error page. }
Example #13
Source File: JettyHandler.java From reef with Apache License 2.0 | 5 votes |
/** * handle http request. * * @param target * @param request * @param response * @param i * @throws IOException * @throws ServletException */ @Override public void handle( final String target, final HttpServletRequest request, final HttpServletResponse response, final int i) throws IOException, ServletException { LOG.log(Level.INFO, "JettyHandler handle is entered with target: {0} ", target); final Request baseRequest = (request instanceof Request) ? (Request) request : HttpConnection.getCurrentConnection().getRequest(); response.setContentType("text/html;charset=utf-8"); final ParsedHttpRequest parsedHttpRequest = new ParsedHttpRequest(request); final HttpHandler handler = validate(request, response, parsedHttpRequest); if (handler != null) { LOG.log(Level.INFO, "calling HttpHandler.onHttpRequest from JettyHandler.handle() for {0}.", handler.getUriSpecification()); handler.onHttpRequest(parsedHttpRequest, response); response.setStatus(HttpServletResponse.SC_OK); } baseRequest.setHandled(true); LOG.log(Level.INFO, "JettyHandler handle exists"); }
Example #14
Source File: SlackNotificationTestProxyServer.java From tcSlackBuildNotifier with MIT License | 5 votes |
@Override public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { System.out.println("Handling Proxy request for " + ((Request) req).getUri().toString()); if ( authRequired ) { final HttpServletRequest request = (HttpServletRequest) req; final HttpServletResponse response = (HttpServletResponse) res; String proxyAuthorization = request.getHeader( "Proxy-Authorization" ); if ( proxyAuthorization != null && proxyAuthorization.startsWith( "Basic " ) ) { String proxyAuth = proxyAuthorization.substring( 6 ); String authorization = B64Code.decode( proxyAuth ); String[] authTokens = authorization.split( ":" ); String user = authTokens[0]; String password = authTokens[1]; if ( user.equals(this.proxyUsername) && password.equals( this.proxyPassword ) ) { super.service(req, res); return; } } // Proxy-Authenticate Basic realm="CCProxy Authorization" response.addHeader( "Proxy-Authenticate", "Basic realm=\"Jetty Proxy Authorization\"" ); response.setStatus( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED ); System.out.println("Proxy Auth Creds not supplied"); } else { super.service(req, res); } }
Example #15
Source File: AppengineAuthenticator.java From yawp with MIT License | 5 votes |
private String getAppengineCookie(Request request) { Cookie[] cookies = request.getCookies(); if (cookies == null) { return null; } for (int i = 0; i < cookies.length; i++) { Cookie cookie = cookies[i]; if (cookie.getName().equals(DEV_APPSERVER_LOGIN_COOKIE)) { return cookie.getValue(); } } return null; }
Example #16
Source File: AppengineAuthenticator.java From yawp with MIT License | 5 votes |
@Override public Principal authenticate(UserRealm realm, String uri, Request request, Response response) throws IOException { String cookie = getAppengineCookie(request); if (isUserLoggedIn(cookie)) { return authenticateInRealm(realm, cookie, request); } if (isLoginUri(uri)) { return NOBODY; } return redirectToLogin(response, uri); }
Example #17
Source File: AppengineUserRealm.java From yawp with MIT License | 5 votes |
@Override public Principal authenticate(String username, Object credentials, Request request) { AppengineUser user = (AppengineUser) credentials; users.put(username, user); helperLogin(username); return user.getPrincipal(); }
Example #18
Source File: ServletReporterImpl.java From vxquery with Apache License 2.0 | 5 votes |
@Override public synchronized void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException { response.setStatus(HttpServletResponse.SC_OK); PrintWriter out = response.getWriter(); reporter.writeHTML(out); out.flush(); ((Request) request).setHandled(true); }
Example #19
Source File: NotFoundHandler.java From anthelion with Apache License 2.0 | 5 votes |
@Override public void handle(Request req, HttpServletResponse res, String target, int dispatch) throws IOException, ServletException { // don't pass it down the chain req.setHandled(true); res.addHeader("X-Handled-By", getClass().getSimpleName()); addMyHeader(res, "URI", req.getUri().toString()); res.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found: " + req.getUri().toString()); }
Example #20
Source File: SLSWebApp.java From hadoop with Apache License 2.0 | 5 votes |
/** * html page for tracking one queue or job * use d3.js * @param request http request * @param response http response * @throws java.io.IOException */ private void printPageTrack(HttpServletRequest request, HttpServletResponse response, int timeunit, String timeunitLabel) throws IOException { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); // tracked queues {0} StringBuilder trackedQueueInfo = new StringBuilder(); Set<String> trackedQueues = wrapper.getQueueSet(); for(String queue : trackedQueues) { trackedQueueInfo.append("<option value='Queue ").append(queue) .append("'>").append(queue).append("</option>"); } // tracked apps {1} StringBuilder trackedAppInfo = new StringBuilder(); Set<String> trackedApps = wrapper.getTrackedAppSet(); for(String job : trackedApps) { trackedAppInfo.append("<option value='Job ").append(job) .append("'>").append(job).append("</option>"); } // timeunit label {2} // time unit {3} // ajax update time {4} // final html String trackInfo = MessageFormat.format(trackTemplate, trackedQueueInfo.toString(), trackedAppInfo.toString(), timeunitLabel, "" + timeunit, "" + ajaxUpdateTimeMS); response.getWriter().println(trackInfo); ((Request) request).setHandled(true); }
Example #21
Source File: SLSWebApp.java From big-c with Apache License 2.0 | 5 votes |
/** * index html page, show simulation info * path "" * @param request http request * @param response http response * @throws java.io.IOException */ private void printPageIndex(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); String simulateInfo; if (SLSRunner.simulateInfoMap.isEmpty()) { String empty = "<tr><td colspan='2' align='center'>" + "No information available</td></tr>"; simulateInfo = MessageFormat.format(simulateInfoTemplate, empty); } else { StringBuilder info = new StringBuilder(); for (Map.Entry<String, Object> entry : SLSRunner.simulateInfoMap.entrySet()) { info.append("<tr>"); info.append("<td class='td1'>").append(entry.getKey()).append("</td>"); info.append("<td class='td2'>").append(entry.getValue()) .append("</td>"); info.append("</tr>"); } simulateInfo = MessageFormat.format(simulateInfoTemplate, info.toString()); } response.getWriter().println(simulateInfo); ((Request) request).setHandled(true); }
Example #22
Source File: SLSWebApp.java From big-c with Apache License 2.0 | 5 votes |
/** * simulate html page, show several real-runtime chart * path "/simulate" * use d3.js * @param request http request * @param response http response * @throws java.io.IOException */ private void printPageSimulate(HttpServletRequest request, HttpServletResponse response, int timeunit, String timeunitLabel) throws IOException { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); // queues {0} Set<String> queues = wrapper.getQueueSet(); StringBuilder queueInfo = new StringBuilder(); int i = 0; for (String queue : queues) { queueInfo.append("legends[4][").append(i).append("] = 'queue.") .append(queue).append(".allocated.memory';"); queueInfo.append("legends[5][").append(i).append("] = 'queue.") .append(queue).append(".allocated.vcores';"); i ++; } // time unit label {1} // time unit {2} // ajax update time interval {3} String simulateInfo = MessageFormat.format(simulateTemplate, queueInfo.toString(), timeunitLabel, "" + timeunit, "" + ajaxUpdateTimeMS); response.getWriter().println(simulateInfo); ((Request) request).setHandled(true); }
Example #23
Source File: SLSWebApp.java From big-c with Apache License 2.0 | 5 votes |
/** * html page for tracking one queue or job * use d3.js * @param request http request * @param response http response * @throws java.io.IOException */ private void printPageTrack(HttpServletRequest request, HttpServletResponse response, int timeunit, String timeunitLabel) throws IOException { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); // tracked queues {0} StringBuilder trackedQueueInfo = new StringBuilder(); Set<String> trackedQueues = wrapper.getQueueSet(); for(String queue : trackedQueues) { trackedQueueInfo.append("<option value='Queue ").append(queue) .append("'>").append(queue).append("</option>"); } // tracked apps {1} StringBuilder trackedAppInfo = new StringBuilder(); Set<String> trackedApps = wrapper.getTrackedAppSet(); for(String job : trackedApps) { trackedAppInfo.append("<option value='Job ").append(job) .append("'>").append(job).append("</option>"); } // timeunit label {2} // time unit {3} // ajax update time {4} // final html String trackInfo = MessageFormat.format(trackTemplate, trackedQueueInfo.toString(), trackedAppInfo.toString(), timeunitLabel, "" + timeunit, "" + ajaxUpdateTimeMS); response.getWriter().println(trackInfo); ((Request) request).setHandled(true); }
Example #24
Source File: SLSWebApp.java From big-c with Apache License 2.0 | 5 votes |
/** * package metrics information in a json and return * @param request http request * @param response http response * @throws java.io.IOException */ private void printJsonMetrics(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/json"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println(generateRealTimeTrackingMetrics()); ((Request) request).setHandled(true); }
Example #25
Source File: SLSWebApp.java From hadoop with Apache License 2.0 | 5 votes |
/** * simulate html page, show several real-runtime chart * path "/simulate" * use d3.js * @param request http request * @param response http response * @throws java.io.IOException */ private void printPageSimulate(HttpServletRequest request, HttpServletResponse response, int timeunit, String timeunitLabel) throws IOException { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); // queues {0} Set<String> queues = wrapper.getQueueSet(); StringBuilder queueInfo = new StringBuilder(); int i = 0; for (String queue : queues) { queueInfo.append("legends[4][").append(i).append("] = 'queue.") .append(queue).append(".allocated.memory';"); queueInfo.append("legends[5][").append(i).append("] = 'queue.") .append(queue).append(".allocated.vcores';"); i ++; } // time unit label {1} // time unit {2} // ajax update time interval {3} String simulateInfo = MessageFormat.format(simulateTemplate, queueInfo.toString(), timeunitLabel, "" + timeunit, "" + ajaxUpdateTimeMS); response.getWriter().println(simulateInfo); ((Request) request).setHandled(true); }
Example #26
Source File: SLSWebApp.java From hadoop with Apache License 2.0 | 5 votes |
/** * index html page, show simulation info * path "" * @param request http request * @param response http response * @throws java.io.IOException */ private void printPageIndex(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); String simulateInfo; if (SLSRunner.simulateInfoMap.isEmpty()) { String empty = "<tr><td colspan='2' align='center'>" + "No information available</td></tr>"; simulateInfo = MessageFormat.format(simulateInfoTemplate, empty); } else { StringBuilder info = new StringBuilder(); for (Map.Entry<String, Object> entry : SLSRunner.simulateInfoMap.entrySet()) { info.append("<tr>"); info.append("<td class='td1'>").append(entry.getKey()).append("</td>"); info.append("<td class='td2'>").append(entry.getValue()) .append("</td>"); info.append("</tr>"); } simulateInfo = MessageFormat.format(simulateInfoTemplate, info.toString()); } response.getWriter().println(simulateInfo); ((Request) request).setHandled(true); }
Example #27
Source File: DelayHandler.java From anthelion with Apache License 2.0 | 5 votes |
@Override public void handle(Request req, HttpServletResponse res, String target, int dispatch) throws IOException, ServletException { try { int del = random ? r.nextInt(delay) : delay; Thread.sleep(del); addMyHeader(res, "Delay", String.valueOf(del)); } catch (Exception e) { } }
Example #28
Source File: AbstractTestbedHandler.java From anthelion with Apache License 2.0 | 5 votes |
@Override public void handle(String target, HttpServletRequest req, HttpServletResponse res, int dispatch) throws IOException, ServletException { Request base_request = (req instanceof Request) ? (Request)req : HttpConnection.getCurrentConnection().getRequest(); res.addHeader("X-TestbedHandlers", this.getClass().getSimpleName()); handle(base_request, res, target, dispatch); }
Example #29
Source File: LogDebugHandler.java From anthelion with Apache License 2.0 | 4 votes |
@Override public void handle(Request req, HttpServletResponse res, String target, int dispatch) throws IOException, ServletException { LOG.info("-- " + req.getMethod() + " " + req.getUri().toString() + "\n" + req.getConnection().getRequestFields()); }
Example #30
Source File: LogDebugHandler.java From nutch-htmlunit with Apache License 2.0 | 4 votes |
@Override public void handle(Request req, HttpServletResponse res, String target, int dispatch) throws IOException, ServletException { LOG.info("-- " + req.getMethod() + " " + req.getUri().toString() + "\n" + req.getConnection().getRequestFields()); }