Java Code Examples for javax.servlet.http.HttpServletResponse

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project accesointeligente, under directory /src/org/accesointeligente/server/.

Source file: GWTCacheControlFilter.java

  21 
vote

public void doFilter(ServletRequest request,ServletResponse response,FilterChain filterChain) throws IOException, ServletException {
  HttpServletRequest httpRequest=(HttpServletRequest)request;
  String requestURI=httpRequest.getRequestURI();
  if (requestURI.contains(".nocache.")) {
    Date now=new Date();
    HttpServletResponse httpResponse=(HttpServletResponse)response;
    httpResponse.setDateHeader("Date",now.getTime());
    httpResponse.setDateHeader("Expires",now.getTime() - 86400000L);
    httpResponse.setHeader("Pragma","no-cache");
    httpResponse.setHeader("Cache-control","no-cache, no-store, must-revalidate");
  }
  filterChain.doFilter(request,response);
}
 

Example 2

From project alfredo, under directory /alfredo/src/test/java/com/cloudera/alfredo/server/.

Source file: TestKerberosAuthenticationHandler.java

  20 
vote

public void testRequestWithoutAuthorization() throws Exception {
  HttpServletRequest request=Mockito.mock(HttpServletRequest.class);
  HttpServletResponse response=Mockito.mock(HttpServletResponse.class);
  assertNull(handler.authenticate(request,response));
  Mockito.verify(response).setHeader(KerberosAuthenticator.WWW_AUTHENTICATE,KerberosAuthenticator.NEGOTIATE);
  Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
 

Example 3

From project AdServing, under directory /modules/server/adserver/src/main/java/net/mad/ads/server/utils/http/listener/.

Source file: AdContextListener.java

  19 
vote

@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  HttpServletRequest req=(HttpServletRequest)request;
  HttpServletResponse res=(HttpServletResponse)response;
  AdContext context=AdContextHelper.getAdContext(req,res);
  ADCONTEXT.set(context);
  chain.doFilter(request,response);
  ADCONTEXT.remove();
}
 

Example 4

From project aerogear-controller, under directory /src/main/java/org/jboss/aerogear/controller/filter/.

Source file: AeroGear.java

  18 
vote

@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  if (!isHttpServletContainer(request,response)) {
    throw LoggerMessages.MESSAGES.mustRunInsideAContainer();
  }
  HttpServletRequest httpServletRequest=(HttpServletRequest)request;
  HttpServletResponse httpServletResponse=(HttpServletResponse)response;
  if (router.hasRouteFor(httpServletRequest)) {
    router.dispatch(httpServletRequest,httpServletResponse,chain);
    return;
  }
  chain.doFilter(request,response);
}
 

Example 5

From project airlift, under directory /http-server/src/main/java/io/airlift/http/server/.

Source file: GZipRequestFilter.java

  18 
vote

public void doFilter(ServletRequest servletRequest,ServletResponse servletResponse,FilterChain filterChain) throws IOException, ServletException {
  HttpServletRequest request=(HttpServletRequest)servletRequest;
  HttpServletResponse response=(HttpServletResponse)servletResponse;
  String contentEncoding=request.getHeader("content-encoding");
  if (equalsIgnoreCase(contentEncoding,"gzip")) {
    filterChain.doFilter(new GZipRequestWrapper(request),servletResponse);
  }
 else {
    filterChain.doFilter(request,response);
  }
}
 

Example 6

From project alphaportal_dev, under directory /sys-src/alphaportal/web/src/test/java/alpha/portal/webapp/controller/.

Source file: CaseFormControllerTest.java

  18 
vote

/** 
 * Test new.
 * @throws Exception the exception
 */
@Test public void testNew() throws Exception {
  final MockHttpServletRequest request=this.newGet("/caseform");
  request.setRemoteUser("admin");
  final HttpServletResponse response=new MockHttpServletResponse();
  final ModelAndView mv=this.form.showForm(this.filters,request,response);
  Assert.assertNotNull(mv);
  Assert.assertEquals("caseform",mv.getViewName());
  Assert.assertEquals(new AlphaCase(),mv.getModel().get("case"));
}
 

Example 7

From project amber, under directory /oauth-2.0/resourceserver-filter/src/main/java/org/apache/amber/oauth2/rsfilter/.

Source file: OAuthFilter.java

  17 
vote

@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  HttpServletRequest req=(HttpServletRequest)request;
  HttpServletResponse res=(HttpServletResponse)response;
  try {
    OAuthAccessResourceRequest oauthRequest=new OAuthAccessResourceRequest(req,parameterStyles);
    String accessToken=oauthRequest.getAccessToken();
    final OAuthDecision decision=provider.validateRequest(realm,accessToken,req);
    final Principal principal=decision.getPrincipal();
    request=new HttpServletRequestWrapper((HttpServletRequest)request){
      @Override public String getRemoteUser(){
        return principal != null ? principal.getName() : null;
      }
      @Override public Principal getUserPrincipal(){
        return principal;
      }
    }
;
    request.setAttribute(OAuth.OAUTH_CLIENT_ID,decision.getOAuthClient().getClientId());
    chain.doFilter(request,response);
    return;
  }
 catch (  OAuthSystemException e1) {
    throw new ServletException(e1);
  }
catch (  OAuthProblemException e) {
    respondWithError(res,e);
    return;
  }
}
 

Example 8

From project aranea, under directory /server/src/test/java/no/dusken/aranea/web/control/.

Source file: IssueControllerTest.java

  17 
vote

@Test public void noThisYear() throws PageNotFoundException {
  int year=(new GregorianCalendar()).get(GregorianCalendar.YEAR);
  List<Issue> issuesPreviousYear=new LinkedList<Issue>();
  issuesPreviousYear.add(new Issue());
  when(issueService.getIssuesPublished(year)).thenReturn(Collections.<Issue>emptyList());
  when(issueService.getIssuesPublished(year - 1)).thenReturn(issuesPreviousYear);
  HttpServletRequest request=mock(HttpServletRequest.class);
  HttpServletResponse response=mock(HttpServletResponse.class);
  ModelAndView modelAndView=controller.handleRequestInternal(request,response);
  assertNotNull(modelAndView);
  assertTrue("Model was empty",!modelAndView.getModel().isEmpty());
  Map<Integer,Collection> issues=(Map<Integer,Collection>)modelAndView.getModel().get("issueMap");
  assertTrue("issues has wrong value",issues.get(year).size() == 0);
  assertTrue("issues has wrong value",issues.get(year - 1).size() == 1);
}
 

Example 9

From project AceWiki, under directory /src/ch/uzh/ifi/attempto/acewiki/.

Source file: AceWikiServlet.java

  16 
vote

protected void process(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  String showpageParam=request.getParameter("showpage");
  if ("".equals(showpageParam))   showpageParam=null;
  String pageParam=request.getParameter("page");
  if ("".equals(pageParam))   pageParam=null;
  String serviceidParam=request.getParameter("sid");
  if ("".equals(serviceidParam))   serviceidParam=null;
  if (!request.getSession().isNew() && showpageParam != null) {
    response.sendRedirect(response.encodeRedirectURL("?sid=ExternalEvent&page=" + showpageParam));
  }
  if (showpageParam == null && pageParam != null && serviceidParam == null) {
    response.sendRedirect(response.encodeRedirectURL("."));
  }
  try {
    super.process(request,response);
  }
 catch (  RuntimeException ex) {
    logger.log("fail","fatal error: " + ex);
    ex.printStackTrace();
    throw ex;
  }
catch (  IOException ex) {
    logger.log("fail","fatal error: " + ex);
    ex.printStackTrace();
    throw ex;
  }
catch (  ServletException ex) {
    logger.log("fail","fatal error: " + ex);
    ex.printStackTrace();
    throw ex;
  }
}
 

Example 10

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/gameserver/.

Source file: ServerServlet.java

  15 
vote

@Override public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException {
  res.setContentType("text/html");
  OutputStream o=res.getOutputStream();
  o.write(("<html>\n").getBytes());
  o.write(("\t<head>\n").getBytes());
  o.write(("\t<title>Applets</title>\n").getBytes());
  o.write(("\t</head>\n").getBytes());
  o.write(("\t<body>\n").getBytes());
  o.write(("\tOverview:<br>\n").getBytes());
  for (  CompileUnit applet : server.appletCompiler.getApplets()) {
    String filename=applet.getJarName().substring(applet.getJarName().lastIndexOf("/") + 1);
    o.write(("\t\t<APPLET codebase='data/' code='" + applet.mainClass.replace(".","/") + ".class' archive='"+ filename+ "'></APPLET><br/>\n").getBytes());
  }
  o.write(("\t</body>\n").getBytes());
  o.write(("</html>\n").getBytes());
  o.flush();
  o.close();
}
 

Example 11

From project activiti-explorer, under directory /src/main/java/org/activiti/explorer/.

Source file: ExplorerApp.java

  15 
vote

public void onRequestStart(HttpServletRequest request,HttpServletResponse response){
  current.set(this);
  LoggedInUser user=(LoggedInUser)getUser();
  if (user == null) {
    user=loginHandler.authenticate(request,response);
    if (user == null) {
      if (mainWindow != null && !mainWindow.isShowingLoginPage()) {
        viewManager.showLoginPage();
      }
    }
 else {
      setUser(user);
    }
  }
  if (user != null) {
    Authentication.setAuthenticatedUserId(user.getId());
    if (mainWindow != null && mainWindow.isShowingLoginPage()) {
      viewManager.showDefaultPage();
    }
  }
  loginHandler.onRequestStart(request,response);
}
 

Example 12

From project aether-core, under directory /aether-connector-asynchttpclient/src/test/java/org/eclipse/aether/connector/async/.

Source file: Generate.java

  15 
vote

public boolean execute(HttpServletRequest request,HttpServletResponse response,Map<Object,Object> ctx) throws Exception {
  if ("GET".equals(request.getMethod())) {
    String path=request.getPathInfo();
    Long length=lengths.get(path);
    if (length != null) {
      response.setContentType("application/octet-stream");
      response.setContentLength(length.intValue());
      ServletOutputStream out=response.getOutputStream();
      for (int i=length.intValue(); i > 0; ) {
        int n=Math.min(i,bytes.length);
        i-=n;
        out.write(bytes,0,n);
      }
      out.close();
      return false;
    }
  }
  return true;
}
 

Example 13

From project agile, under directory /agile-framework/src/main/java/org/apache/catalina/servlets/.

Source file: DefaultServlet.java

  15 
vote

/** 
 * Process a GET request for the specified resource.
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet-specified error occurs
 */
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  if (!isAuthenticated(request,response) || !isAuthorized(request,response)) {
    response.sendError(HttpServletResponse.SC_FORBIDDEN);
    return;
  }
  serveResource(request,response,true);
}
 

Example 14

From project agileBase, under directory /gtpb_server/src/com/gtwm/pb/servlets/.

Source file: AppController.java

  15 
vote

/** 
 * Optionally return application/xml or other content rather than the default text/html If there is no returntype specified, don't set a header, but return ResponseReturnType.HTML This can be useful when using AJAX interfaces with XMLHttpRequest in the browser
 */
public static ResponseReturnType setReturnType(HttpServletRequest request,HttpServletResponse response,List<FileItem> multipartItems){
  String returnType=ServletUtilMethods.getParameter(request,"returntype",multipartItems);
  ResponseReturnType responseReturnType=ResponseReturnType.HTML;
  if (returnType != null) {
    try {
      responseReturnType=ResponseReturnType.valueOf(returnType.toUpperCase());
      response.setContentType(responseReturnType.getResponseType());
      if (responseReturnType.equals(ResponseReturnType.DOWNLOAD)) {
        String filename=ServletUtilMethods.getParameter(request,"returnfilename",multipartItems);
        response.setHeader("Content-Disposition","attachment;filename=\"" + filename + "\"");
      }
    }
 catch (    IllegalArgumentException iaex) {
      EnumSet<ResponseReturnType> allReturnTypes=EnumSet.allOf(ResponseReturnType.class);
      ServletUtilMethods.logException(iaex,request,"Unknown returntype specified: " + returnType + " - must be one of "+ allReturnTypes);
    }
  }
  return responseReturnType;
}
 

Example 15

From project agraph-java-client, under directory /src/test/web/.

Source file: AGTestServlet.java

  15 
vote

@Override protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  Closer c=new Closer();
  try {
    Context initCtx=c.closeLater(new InitialContext());
    Context envCtx=(Context)c.closeLater(initCtx.lookup("java:comp/env"));
    AGConnPool pool=(AGConnPool)envCtx.lookup("connection-pool/agraph");
    AGRepositoryConnection conn=c.closeLater(pool.borrowConnection());
    resp.getWriter().println("size=" + conn.size());
    resp.getWriter().flush();
  }
 catch (  Exception e) {
    throw new ServletException(e);
  }
 finally {
    c.close();
  }
}
 

Example 16

From project ajah, under directory /ajah-event-http/src/main/java/com/ajah/log/http/servlet/filter/.

Source file: AccessLoggerFilter.java

  15 
vote

/** 
 * Logs requests.
 */
@Override public void doFilter(final HttpServletRequest request,final HttpServletResponse response,final FilterChain chain) throws IOException, ServletException {
  final RequestEvent requestEvent=new RequestEvent(request);
  request.setAttribute("ajahRequestEvent",requestEvent);
  try {
    chain.doFilter(request,response);
  }
  finally {
    requestEvent.complete();
    if (isLoggable(request)) {
      log.finest(requestEvent.getUri() + " took " + requestEvent.getDuration()+ "ms");
      AjahUtils.requireParam(this.taskExecutor,"taskExecutor");
      this.taskExecutor.execute(new RequestEventHandler(requestEvent,this.requestEventManager));
    }
  }
}
 

Example 17

From project ALP, under directory /workspace/alp-reporter-fe/src/main/java/com/lohika/alp/reporter/fe/controller/.

Source file: LogController.java

  15 
vote

@RequestMapping(method=RequestMethod.POST,value="/results/test-method/{testMethodId}/log") void saveLog(@PathVariable("testMethodId") long id,@ModelAttribute("uploadItem") UploadItem uploadItem,HttpServletRequest request,HttpServletResponse response) throws IOException {
  CommonsMultipartFile fileData=uploadItem.getFileData();
  String name=fileData.getOriginalFilename();
  InputStream is=fileData.getInputStream();
  ServletContext sc=request.getSession().getServletContext();
  String datalogsPath=sc.getInitParameter("datalogsPath");
  if (name.toLowerCase().endsWith(".xml") || !name.matches(".*\\.\\w{1,3}$")) {
    logStorage.saveLog(id,"index.xml",is,datalogsPath);
    TestMethod testMethod=testMethodDAO.getTestMethod(id);
    testMethod.setHasLog(true);
    testMethodDAO.saveTestMethod(testMethod);
  }
 else {
    logStorage.saveLog(id,name,is,datalogsPath);
  }
  response.setStatus(HttpServletResponse.SC_CREATED);
}
 

Example 18

From project Amantech, under directory /Android/testtest/src/guestbook/.

Source file: SignGuestbookServlet.java

  15 
vote

public void doPost(HttpServletRequest req,HttpServletResponse resp) throws IOException {
  UserService userService=UserServiceFactory.getUserService();
  User user=userService.getCurrentUser();
  String guestbookName=req.getParameter("guestbookName");
  Key guestbookKey=KeyFactory.createKey("Guestbook",guestbookName);
  String content=req.getParameter("content");
  Date date=new Date();
  Entity greeting=new Entity("Greeting",guestbookKey);
  greeting.setProperty("user",user);
  greeting.setProperty("date",date);
  greeting.setProperty("content",content);
  DatastoreService datastore=DatastoreServiceFactory.getDatastoreService();
  datastore.put(greeting);
  resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);
}
 

Example 19

From project ambrose, under directory /common/src/main/java/com/twitter/ambrose/server/.

Source file: APIHandler.java

  15 
vote

@Override public void handle(String target,HttpServletRequest request,HttpServletResponse response,int dispatch) throws IOException, ServletException {
  if (target.endsWith("/dag")) {
    response.setContentType(MIME_TYPE_JSON);
    response.setStatus(HttpServletResponse.SC_OK);
    Collection<DAGNode> nodes=statsReadService.getDagNodeNameMap(request.getParameter(QUERY_PARAM_WORKFLOW_ID)).values();
    DAGTransformer dagTransformer=new SugiyamaLayoutTransformer(true);
    dagTransformer.transform(nodes);
    sendJson(request,response,nodes.toArray(new DAGNode[nodes.size()]));
  }
 else   if (target.endsWith("/events")) {
    response.setContentType(MIME_TYPE_JSON);
    response.setStatus(HttpServletResponse.SC_OK);
    Integer sinceId=request.getParameter(QUERY_PARAM_SINCE) != null ? Integer.getInteger(request.getParameter(QUERY_PARAM_SINCE)) : -1;
    Collection<WorkflowEvent> events=statsReadService.getEventsSinceId(request.getParameter(QUERY_PARAM_WORKFLOW_ID),sinceId);
    sendJson(request,response,events.toArray(new WorkflowEvent[events.size()]));
  }
 else   if (target.endsWith(".html")) {
    response.setContentType(MIME_TYPE_HTML);
  }
}
 

Example 20

From project android-joedayz, under directory /Proyectos/spring-rest-cliente/src/main/java/com/mycompany/rest/client/controller/.

Source file: RestClientController.java

  15 
vote

/** 
 * Retrieves an image from the REST provider and writes the response to an output stream.
 */
@RequestMapping(value="/getphoto",method=RequestMethod.GET) public void getPhoto(@RequestParam("id") Long id,HttpServletResponse response){
  logger.debug("Retrieve photo with id: " + id);
  List<MediaType> acceptableMediaTypes=new ArrayList<MediaType>();
  acceptableMediaTypes.add(MediaType.IMAGE_JPEG);
  HttpHeaders headers=new HttpHeaders();
  headers.setAccept(acceptableMediaTypes);
  HttpEntity<String> entity=new HttpEntity<String>(headers);
  ResponseEntity<byte[]> result=restTemplate.exchange("http://localhost:8080/spring-rest-provider/krams/person/{id}",HttpMethod.GET,entity,byte[].class,id);
  Writer.write(response,result.getBody());
}
 

Example 21

From project androidpn, under directory /androidpn-server-bin-tomcat/src/org/androidpn/server/console/api/.

Source file: NotificationApiController.java

  15 
vote

public void send(HttpServletRequest request,HttpServletResponse response) throws Exception {
  String broadcast=ServletRequestUtils.getStringParameter(request,"broadcast","Y");
  String username=ServletRequestUtils.getStringParameter(request,"username");
  String title=ServletRequestUtils.getStringParameter(request,"title");
  String message=ServletRequestUtils.getStringParameter(request,"message");
  String uri=ServletRequestUtils.getStringParameter(request,"uri");
  String apiKey=Config.getString("apiKey","");
  logger.debug("apiKey=" + apiKey);
  if (broadcast.equalsIgnoreCase("Y")) {
    notificationManager.sendBroadcast(apiKey,title,message,uri);
  }
 else {
    notificationManager.sendNotifcationToUser(apiKey,username,title,message,uri);
  }
  response.getWriter().print("{\"result\":\"0\",\"description\":\"success\"}");
}
 

Example 22

From project ANNIS, under directory /annis-gui/src/main/java/annis/gui/.

Source file: MainApp.java

  15 
vote

@Override public void onRequestStart(HttpServletRequest request,HttpServletResponse response){
  String origURI=request.getRequestURI();
  String parameters=origURI.replaceAll(".*?/Cite(/)?","");
  if (!"".equals(parameters) && !origURI.equals(parameters)) {
    try {
      String decoded=URLDecoder.decode(parameters,"UTF-8");
      getWindowSearch().evaluateCitation(decoded);
      try {
        response.sendRedirect(getURL().toString());
      }
 catch (      IOException ex) {
        log.error(null,ex);
      }
    }
 catch (    UnsupportedEncodingException ex) {
      log.error(null,ex);
    }
  }
}
 

Example 23

From project annotare2, under directory /app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/.

Source file: LoginServlet.java

  15 
vote

@Override protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  log.debug("Login details submitted; validating..");
  ValidationErrors errors=new ValidationErrors();
  try {
    errors.append(authService.login(request));
    if (errors.isEmpty()) {
      log.debug("Login details are valid; Authorization succeeded");
      HOME.restoreAndRedirect(request,response);
      return;
    }
    log.debug("Login detail are invalid");
  }
 catch (  LoginException e) {
    log.debug("Authorization failed");
    errors.append(e.getMessage());
  }
  request.setAttribute("errors",errors);
  LOGIN.forward(getServletConfig().getServletContext(),request,response);
}
 

Example 24

From project any23, under directory /service/src/main/java/org/apache/any23/servlet/.

Source file: RedirectServlet.java

  15 
vote

protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  final String pathInfo=request.getPathInfo();
  final String queryString=request.getQueryString();
  if (("/".equals(pathInfo) && queryString == null)) {
    getServletContext().getRequestDispatcher("/resources/form.html").forward(request,response);
    return;
  }
  if (pathInfo.startsWith("/resources/")) {
    getServletContext().getNamedDispatcher("default").forward(request,response);
    return;
  }
  response.sendRedirect(request.getContextPath() + "/any23" + request.getPathInfo()+ (queryString == null ? "" : "?" + queryString));
}
 

Example 25

From project api-sdk-java, under directory /api-sdk/src/main/java/com/smartling/api/sdk/file/.

Source file: FileApiClientAdapterImpl.java

  15 
vote

private StringResponse executeHttpcall(HttpRequestBase httpRequest) throws FileApiException {
  HttpClient httpClient=null;
  try {
    httpClient=new DefaultHttpClient();
    setupProxy(httpClient);
    HttpResponse response=httpClient.execute(httpRequest);
    if (response.getStatusLine().getStatusCode() == HttpServletResponse.SC_OK)     return inputStreamToString(response.getEntity().getContent(),null);
    throw new FileApiException(inputStreamToString(response.getEntity().getContent(),null).getContents());
  }
 catch (  IOException e) {
    throw new FileApiException(e);
  }
 finally {
    if (null != httpClient)     httpClient.getConnectionManager().shutdown();
  }
}
 

Example 26

From project appengine-java-mapreduce, under directory /java/src/com/google/appengine/tools/mapreduce/impl/handlers/.

Source file: MapReduceServletImpl.java

  15 
vote

/** 
 * Handle GET http requests.
 */
public static void doGet(HttpServletRequest request,HttpServletResponse response){
  String handler=getHandler(request);
  if (handler.startsWith(COMMAND_PATH)) {
    if (!checkForAjax(request,response)) {
      return;
    }
    StatusHandler.handleCommand(handler.substring(COMMAND_PATH.length() + 1),request,response);
  }
 else {
    handleStaticResources(handler,response);
  }
}
 

Example 27

From project arquillian-container-openshift, under directory /openshift-express/src/main/java/org/jboss/arquillian/container/openshift/express/ping/.

Source file: DeploymentServlet.java

  15 
vote

@Override protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  String deploymentName=req.getParameter("name");
  if (deploymentName == null) {
    returnFalse(resp);
  }
  if (deploymentExists(deploymentName)) {
    returnTrue(resp);
  }
 else {
    returnFalse(resp);
  }
}
 

Example 28

From project arquillian-core, under directory /protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/runner/.

Source file: ServletTestRunner.java

  15 
vote

public void executeTest(HttpServletResponse response,String outputMode,String className,String methodName) throws ClassNotFoundException, IOException {
  Class<?> testClass=SecurityActions.getThreadContextClassLoader().loadClass(className);
  TestRunner runner=TestRunners.getTestRunner();
  TestResult testResult=runner.execute(testClass,methodName);
  if (OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode)) {
    writeObject(testResult,response);
  }
 else {
    response.setContentType("text/html");
    response.setStatus(HttpServletResponse.SC_OK);
    PrintWriter writer=response.getWriter();
    writer.write("<html>\n");
    writer.write("<head><title>TCK Report</title></head>\n");
    writer.write("<body>\n");
    writer.write("<h2>Configuration</h2>\n");
    writer.write("<table>\n");
    writer.write("<tr>\n");
    writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
    writer.write("</tr>\n");
    writer.write("</table>\n");
    writer.write("<h2>Tests</h2>\n");
    writer.write("<table>\n");
    writer.write("<tr>\n");
    writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
    writer.write("</tr>\n");
    writer.write("</table>\n");
    writer.write("</body>\n");
  }
}