List of usage examples for javax.servlet RequestDispatcher forward
public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException;
From source file:controllers.ServerController.java
public void login(HttpServletRequest request, HttpServletResponse response) throws IOException, InterruptedException, ServletException, LDAPException { try {//from ww w . ja va 2 s . co m LDAPConnection c = new LDAPConnection("192.168.1.10", 389, "cn=" + request.getParameter("username") + ",ou=printing,dc=iliberis,dc=com", (String) request.getParameter("password")); if (c.isConnected()) { HttpSession session = LDAPConn.getInstance().loadGroups(request); ServerController.getInstance().listPrinter(request, response); RequestDispatcher rd; List<String> groups = (List<String>) session.getAttribute("groups"); if (groups.contains("10000")) { rd = request.getRequestDispatcher("admin.jsp"); request.setAttribute("groupsList", LDAPConn.getInstance().getPrintingGroups()); } else rd = request.getRequestDispatcher("success.jsp"); rd.forward(request, response); } } catch (LDAPException ex) { // LDAPException(resultCode=49): Credenciales invalidas // LDAPException(resultCode=89): DN o pass vacios System.out.println("No connection: " + ex.getExceptionMessage()); Logger.getLogger(MainServlet.class.getName()).log(Level.SEVERE, null, ex); RequestDispatcher rd = request.getRequestDispatcher("index.html"); rd.forward(request, response); } catch (Exception ex) { Logger.getLogger(ServerController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:gov.nih.nci.security.cgmm.authenticators.CaGridFormAuthenticator.java
/** * Called to forward to the login page/* w w w . j a va 2 s .c o m*/ * * @param request Request we are processing * @param response Response we are creating * @param config Login configuration describing how authentication * should be performed */ protected void forwardToLoginPage(Request request, Response response, LoginConfig config) { RequestDispatcher disp = context.getServletContext().getRequestDispatcher(config.getLoginPage()); try { disp.forward(request.getRequest(), response.getResponse()); response.finishResponse(); } catch (Throwable t) { log.warn("Unexpected error forwarding to login page", t); } }
From source file:org.zkoss.zk.grails.web.ZULUrlMappingsFilter.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override/*w w w . j ava 2 s .c o m*/ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { UrlMappingsHolder holder = WebUtils.lookupUrlMappings(getServletContext()); String uri = urlHelper.getPathWithinApplication(request); if (uri.startsWith("/zkau") || uri.startsWith("/zkcomet") || uri.startsWith("/dbconsole") || uri.startsWith("/ext") || uri.startsWith("~.")) { LOG.debug("Excluding: " + uri); processFilterChain(request, response, filterChain); return; } if (!"/".equals(uri) && noControllers() && noComposers() && noRegexMappings(holder)) { // not index request, no controllers, and no URL mappings for views, so it's not a Grails request LOG.debug( "not index request, no controllers, and no URL mappings for views, so it's not a Grails request"); processFilterChain(request, response, filterChain); return; } if (isUriExcluded(holder, uri)) { LOG.debug("Excluded by pattern: " + uri); processFilterChain(request, response, filterChain); return; } if (LOG.isDebugEnabled()) { LOG.debug("Executing URL mapping filter..."); LOG.debug(holder); } if (areFileExtensionsEnabled()) { String format = WebUtils.getFormatFromURI(uri, mimeTypes); if (format != null) { MimeType[] configuredMimes = mimeTypes == null ? MimeType.getConfiguredMimeTypes() : mimeTypes; // only remove the file extension if it's one of the configured mimes in Config.groovy for (MimeType configuredMime : configuredMimes) { if (configuredMime.getExtension().equals(format)) { request.setAttribute(GrailsApplicationAttributes.RESPONSE_FORMAT, format); uri = uri.substring(0, (uri.length() - format.length() - 1)); break; } } } } GrailsWebRequest webRequest = (GrailsWebRequest) request .getAttribute(GrailsApplicationAttributes.WEB_REQUEST); UrlMappingInfo[] urlInfos = holder.matchAll(uri); WrappedResponseHolder.setWrappedResponse(response); boolean dispatched = false; try { // GRAILS-3369: Save the original request parameters. Map backupParameters; try { backupParameters = new HashMap(webRequest.getParams()); } catch (Exception e) { LOG.error("Error creating params object: " + e.getMessage(), e); backupParameters = Collections.EMPTY_MAP; } for (UrlMappingInfo info : urlInfos) { if (info != null) { // GRAILS-3369: The configure() will modify the // parameter map attached to the web request. So, // we need to clear it each time and restore the // original request parameters. webRequest.getParams().clear(); webRequest.getParams().putAll(backupParameters); final String viewName; try { info.configure(webRequest); String action = info.getActionName() == null ? "" : info.getActionName(); viewName = info.getViewName(); if (viewName == null && info.getURI() == null) { final String controllerName = info.getControllerName(); String pluginName = info.getPluginName(); String featureUri = WebUtils.SLASH + urlConverter.toUrlElement(controllerName) + WebUtils.SLASH + urlConverter.toUrlElement(action); Object featureId = null; if (pluginName != null) { Map featureIdMap = new HashMap(); featureIdMap.put("uri", featureUri); featureIdMap.put("pluginName", pluginName); featureId = featureIdMap; } else { featureId = featureUri; } GrailsClass controller = application .getArtefactForFeature(ControllerArtefactHandler.TYPE, featureId); if (controller == null) { if (uri.endsWith(".zul")) { RequestDispatcher dispatcher = request.getRequestDispatcher(uri); dispatcher.forward(request, response); dispatched = true; break; } String zul = composerMapping.resolveZul(controllerName); if (zul != null) { RequestDispatcher dispatcher = request.getRequestDispatcher(zul); dispatcher.forward(request, response); dispatched = true; break; } } else { webRequest.setAttribute(GrailsApplicationAttributes.CONTROLLER_NAME_ATTRIBUTE, controller.getLogicalPropertyName(), WebRequest.SCOPE_REQUEST); webRequest.setAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS, controller, WebRequest.SCOPE_REQUEST); // webRequest.setAttribute(GrailsApplicationAttributes. GRAILS_CONTROLLER_CLASS_AVAILABLE, Boolean.TRUE, WebRequest.SCOPE_REQUEST); } } } catch (Exception e) { if (e instanceof MultipartException) { reapplySitemesh(request); throw ((MultipartException) e); } LOG.error("Error when matching URL mapping [" + info + "]:" + e.getMessage(), e); continue; } dispatched = true; if (!WAR_DEPLOYED) { checkDevelopmentReloadingState(request); } request = checkMultipart(request); if (viewName == null || (viewName.endsWith(GSP_SUFFIX) || viewName.endsWith(JSP_SUFFIX))) { if (info.isParsingRequest()) { webRequest.informParameterCreationListeners(); } String forwardUrl = WebUtils.forwardRequestForUrlMappingInfo(request, response, info); if (LOG.isDebugEnabled()) { LOG.debug("Matched URI [" + uri + "] to URL mapping [" + info + "], forwarding to [" + forwardUrl + "] with response [" + response.getClass() + "]"); } } else if (viewName != null && viewName.endsWith(ZUL_SUFFIX)) { RequestDispatcher dispatcher = request.getRequestDispatcher(viewName); dispatcher.forward(request, response); } else { if (viewName == null) { dispatched = false; } else if (!renderViewForUrlMappingInfo(request, response, info, viewName)) { dispatched = false; } } break; } } // for } finally { WrappedResponseHolder.setWrappedResponse(null); } if (!dispatched) { if (LOG.isDebugEnabled()) { LOG.debug("No match found, processing remaining filter chain."); } processFilterChain(request, response, filterChain); } }
From source file:eu.earthobservatory.org.StrabonEndpoint.DescribeBean.java
/** * Processes the request made from the HTML visual interface of Strabon Endpoint. * /*from ww w. ja va 2 s. c o m*/ * @param request * @param response * @throws ServletException * @throws IOException */ private void processVIEWRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // get the dispatcher for forwarding the rendering of the response RequestDispatcher dispatcher = request.getRequestDispatcher("describe.jsp"); String query = URLDecoder.decode(request.getParameter("query"), "UTF-8"); String format = request.getParameter("format"); String handle = request.getParameter("handle"); RDFFormat rdfFormat = RDFFormat.valueOf(format); if (format == null || query == null || rdfFormat == null) { request.setAttribute(ERROR, PARAM_ERROR); dispatcher.forward(request, response); } else { // set the query, format and handle to be selected in the rendered page //request.setAttribute("query", URLDecoder.decode(query, "UTF-8")); //request.setAttribute("format", URLDecoder.decode(reqFormat, "UTF-8")); //request.setAttribute("handle", URLDecoder.decode(handle, "UTF-8")); if ("download".equals(handle)) { // download as attachment ServletOutputStream out = response.getOutputStream(); response.setContentType(rdfFormat.getDefaultMIMEType()); response.setHeader("Content-Disposition", "attachment; filename=results." + rdfFormat.getDefaultFileExtension() + "; " + rdfFormat.getCharset()); try { strabonWrapper.describe(query, format, out); response.setStatus(HttpServletResponse.SC_OK); } catch (Exception e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); out.print(ResponseMessages.getXMLHeader()); out.print(ResponseMessages.getXMLException(e.getMessage())); out.print(ResponseMessages.getXMLFooter()); } out.flush(); } else //plain { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); strabonWrapper.describe(query, format, bos); request.setAttribute(RESPONSE, StringEscapeUtils.escapeHtml(bos.toString())); } catch (Exception e) { request.setAttribute(ERROR, e.getMessage()); } dispatcher.forward(request, response); } } }
From source file:nl.strohalm.cyclos.struts.CyclosRequestProcessor.java
@Override protected void processPopulate(final HttpServletRequest request, final HttpServletResponse response, final ActionForm form, final ActionMapping mapping) throws ServletException { try {/*from w w w . j a va 2 s . c o m*/ super.processPopulate(request, response, form, mapping); } catch (final Exception e) { LOG.error("Error populating " + form + " in " + mapping.getPath(), e); request.getSession().setAttribute("errorKey", "error.validation"); final RequestDispatcher rd = request.getRequestDispatcher("/do/error"); try { rd.forward(request, response); } catch (final IOException e1) { LOG.error("Error while trying to forward to error page", e1); } } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.RestrictionRetryController.java
public void doGet(HttpServletRequest req, HttpServletResponse response) { if (!isAuthorizedToDisplayPage(req, response, SimplePermission.EDIT_ONTOLOGY.ACTION)) { return;/*from w ww. ja v a 2 s. c o m*/ } VitroRequest request = new VitroRequest(req); try { EditProcessObject epo = createEpo(request); request.setAttribute("editAction", "addRestriction"); epo.setAttribute("VClassURI", request.getParameter("VClassURI")); String restrictionTypeStr = request.getParameter("restrictionType"); epo.setAttribute("restrictionType", restrictionTypeStr); request.setAttribute("restrictionType", restrictionTypeStr); // default to object property restriction boolean propertyType = ("data".equals(request.getParameter("propertyType"))) ? DATA : OBJECT; List<? extends ResourceBean> pList = (propertyType == OBJECT) ? request.getUnfilteredWebappDaoFactory().getObjectPropertyDao().getAllObjectProperties() : request.getUnfilteredWebappDaoFactory().getDataPropertyDao().getAllDataProperties(); List<Option> onPropertyList = new LinkedList<Option>(); sortForPickList(pList, request); for (ResourceBean p : pList) { onPropertyList.add(new Option(p.getURI(), p.getPickListName())); } epo.setFormObject(new FormObject()); epo.getFormObject().getOptionLists().put("onProperty", onPropertyList); if (restrictionTypeStr.equals("someValuesFrom")) { request.setAttribute("specificRestrictionForm", "someValuesFromRestriction_retry.jsp"); List<Option> optionList = (propertyType == OBJECT) ? getValueClassOptionList(request) : getValueDatatypeOptionList(request); epo.getFormObject().getOptionLists().put("ValueClass", optionList); } else if (restrictionTypeStr.equals("allValuesFrom")) { request.setAttribute("specificRestrictionForm", "allValuesFromRestriction_retry.jsp"); List<Option> optionList = (propertyType == OBJECT) ? getValueClassOptionList(request) : getValueDatatypeOptionList(request); epo.getFormObject().getOptionLists().put("ValueClass", optionList); } else if (restrictionTypeStr.equals("hasValue")) { request.setAttribute("specificRestrictionForm", "hasValueRestriction_retry.jsp"); if (propertyType == OBJECT) { request.setAttribute("propertyType", "object"); } else { request.setAttribute("propertyType", "data"); } } else if (restrictionTypeStr.equals("minCardinality") || restrictionTypeStr.equals("maxCardinality") || restrictionTypeStr.equals("cardinality")) { request.setAttribute("specificRestrictionForm", "cardinalityRestriction_retry.jsp"); } RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); request.setAttribute("bodyJsp", "/templates/edit/formBasic.jsp"); request.setAttribute("formJsp", "/templates/edit/specific/restriction_retry.jsp"); request.setAttribute("scripts", "/templates/edit/formBasic.js"); request.setAttribute("title", "Add Restriction"); request.setAttribute("_action", "insert"); setRequestAttributes(request, epo); try { rd.forward(request, response); } catch (Exception e) { log.error(this.getClass().getName() + "PropertyRetryController could not forward to view."); log.error(e.getMessage()); log.error(e.getStackTrace()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.Default.java
public void handleGet(HttpServletRequest request, HttpServletResponse response, String pathInContext, Resource resource, boolean endsWithSlash) throws ServletException, IOException { if (resource == null || !resource.exists()) response.sendError(HttpResponse.__404_Not_Found); else {/*from w w w.j a v a2s .co m*/ // check if directory if (resource.isDirectory()) { if (!endsWithSlash && !pathInContext.equals("/")) { String q = request.getQueryString(); StringBuffer buf = request.getRequestURL(); if (q != null && q.length() != 0) { buf.append('?'); buf.append(q); } response.setContentLength(0); response.sendRedirect(response.encodeRedirectURL(URI.addPaths(buf.toString(), "/"))); return; } // See if index file exists String welcome = _httpContext.getWelcomeFile(resource); if (welcome != null) { String ipath = URI.addPaths(pathInContext, welcome); if (_redirectWelcomeFiles) { // Redirect to the index response.setContentLength(0); response.sendRedirect(URI.addPaths(_httpContext.getContextPath(), ipath)); } else { // Forward to the index RequestDispatcher dispatcher = _servletHandler.getRequestDispatcher(ipath); dispatcher.forward(request, response); } return; } // Check modified dates if (!passConditionalHeaders(request, response, resource)) return; // If we got here, no forward to index took place sendDirectory(request, response, resource, pathInContext.length() > 1); } else { // Check modified dates if (!passConditionalHeaders(request, response, resource)) return; // just send it sendData(request, response, pathInContext, resource); } } }
From source file:com.scooterframework.web.controller.ActionControl.java
/** * <p>Do a forward to specified URI using a <tt>RequestDispatcher</tt>. * This method is used by all methods needing to do a forward.</p> * * @param uri Context-relative URI to forward to * @param request HTTP servlet request//from w ww .j ava2s .c o m * @param response HTTP servlet response * @throws java.io.IOException * @throws javax.servlet.ServletException */ public static void doForward(String uri, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { log.debug("doForward: " + uri); if (uri == null) return; if (uri != null && !uri.startsWith("/")) uri = "/" + uri; RequestDispatcher rd = request.getSession().getServletContext().getRequestDispatcher(uri); if (rd == null) { uri = "/WEB-INF/views/404.jsp"; log.error("Unable to locate \"" + uri + "\", forward to " + uri); rd = getServletContext().getRequestDispatcher(uri); } rd.forward(request, response); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.DataPropertyStatementRetryController.java
public void doPost(HttpServletRequest request, HttpServletResponse response) { if (!isAuthorizedToDisplayPage(request, response, SimplePermission.DO_BACK_END_EDITING.ACTION)) { return;/* w ww . j a v a2s . c o m*/ } //create an EditProcessObject for this and put it in the session EditProcessObject epo = super.createEpo(request); String action = "insert"; VitroRequest vreq = new VitroRequest(request); DataPropertyStatementDao dataPropertyStatementDao = vreq.getUnfilteredWebappDaoFactory() .getDataPropertyStatementDao(); epo.setDataAccessObject(dataPropertyStatementDao); DataPropertyDao dpDao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao(); IndividualDao eDao = vreq.getUnfilteredWebappDaoFactory().getIndividualDao(); epo.setBeanClass(DataPropertyStatement.class); DataPropertyStatement objectForEditing = null; if (!epo.getUseRecycledBean()) { objectForEditing = new DataPropertyStatementImpl(); populateBeanFromParams(objectForEditing, vreq); if (vreq.getParameter(MULTIPLEXED_PARAMETER_NAME) != null) { action = "update"; } epo.setOriginalBean(objectForEditing); } else { objectForEditing = (DataPropertyStatement) epo.getNewBean(); } FormObject foo = new FormObject(); foo.setValues(new HashMap()); HashMap OptionMap = new HashMap(); List entityList = new LinkedList(); if (objectForEditing.getIndividualURI() != null) { Individual individual = eDao.getIndividualByURI(objectForEditing.getIndividualURI()); entityList.add(new Option(individual.getURI(), individual.getName(), true)); } else { entityList.add(new Option("-1", "Error: the individual must be specified", true)); } OptionMap.put("IndividualURI", entityList); DataProperty dp = dpDao.getDataPropertyByURI(objectForEditing.getDatapropURI()); if (dp == null) { foo.getValues().put("Dataprop", "Error: the data property must be specified"); } else { foo.getValues().put("Dataprop", dp.getPublicName()); } foo.setOptionLists(OptionMap); epo.setFormObject(foo); FormUtils.populateFormFromBean(objectForEditing, action, foo); RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); request.setAttribute("bodyJsp", "/templates/edit/formBasic.jsp"); request.setAttribute("formJsp", "/templates/edit/specific/ents2data_retry.jsp"); request.setAttribute("scripts", "/templates/edit/formBasic.js"); request.setAttribute("title", "Individual Data Editing Form"); request.setAttribute("_action", action); request.setAttribute("unqualifiedClassName", "DataPropertyStatement"); setRequestAttributes(request, epo); try { rd.forward(request, response); } catch (Exception e) { log.error(this.getClass().getName() + " could not forward to view."); log.error(e.getMessage()); log.error(e.getStackTrace()); } }
From source file:eu.impact_project.iif.t2.client.WorkflowRunner.java
/** * Executes the chosen workflow by uploading it to taverna server *//*w ww . ja v a2 s. c o m*/ @SuppressWarnings("deprecation") protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // extract all the html form parameters from the request, // including files (files are encoded to base64) Map<String, String> htmlFormItems = Helper.parseRequest(request); // will contain outputs from all ports of all workflows List<List<WorkflowOutputPort>> allOutputs = new ArrayList<List<WorkflowOutputPort>>(); HttpSession session = request.getSession(true); ArrayList<Workflow> workflows = (ArrayList<Workflow>) session.getAttribute("workflows"); try { long duration = 0; long startTime = System.currentTimeMillis(); final String CONFIG_PATH = getServletContext().getRealPath("/") + "config.properties"; File config = new File(CONFIG_PATH); Properties config_prop = new Properties(); FileInputStream config_file = null; try { config_file = new FileInputStream(CONFIG_PATH); } catch (java.io.FileNotFoundException e) { e.printStackTrace(); } try { config_prop.load(config_file); } catch (java.io.IOException e) { e.printStackTrace(); } String address = config_prop.getProperty("tavernaServer"); String cred = config_prop.getProperty("tavernaCred"); // Rewrite adress to form: http://user.password@my.tld // Example https://taverna.taverna@localhost:8443/taverna-server address = address.split("//")[0] + "//" + cred.split(":")[0] + "." + cred.split(":")[1] + "@" + address.split("//")[1]; System.out.println("Using taverna-server: " + address); URI serverURI = new URI(address); Server tavernaRESTClient = new Server(serverURI); if (tavernaRESTClient.equals(null)) { String error = address; System.out.println("ERRORS: " + error); session.setAttribute("errors", "<em style=\"color:red\">Could not create restclient at:</em> <br>" + error); } boolean urlFault = false; List<Run> runIDs = new ArrayList<Run>(); List<String> invalidUrls = new ArrayList<String>(); Run runID = null; UserCredentials user = null; // String cred = "taverna:taverna"; user = new HttpBasicCredentials(cred); int j = 0; // put all the workflows and their inputs onto the server and // execute the corresponding jobs for (Workflow currentWorkflow : workflows) { // upload the workflow to server String workflowAsString = currentWorkflow.getStringVersion(); byte[] currentWorkflowBytes = workflowAsString.getBytes(); String userForm = htmlFormItems.get("user"); String passForm = htmlFormItems.get("pass"); int cont = 0; for (Wsdl currentWsdl : currentWorkflow.getWsdls()) { currentWsdl.setUser(userForm); currentWsdl.setPass(passForm); System.out.print("\n Runner USER : " + currentWsdl.getUser() + "\n"); System.out.print("\n Runner USER : " + currentWsdl.getPass() + "\n"); System.out.print("\n WSDL : " + currentWsdl.getUrl() + "\n"); cont++; } String inputsText = ""; for (String currentInput : htmlFormItems.keySet()) inputsText += htmlFormItems.get(currentInput) + " "; System.out.print("Input form: " + inputsText); currentWorkflow.setUrls(inputsText); for (String currentUrl : currentWorkflow.getUrls()) { if (!currentWorkflow.testUrl(currentUrl)) { urlFault = true; if (!invalidUrls.contains(currentUrl)) invalidUrls.add(currentUrl); System.out.println("Url not available: " + currentUrl); } } if (urlFault) { String error = ""; for (String url : invalidUrls) error += url + "<br>"; System.out.println("ERRORS: " + error); session.setAttribute("errors", "<em style=\"color:red\">Resources not available:</em> <br>" + error); RequestDispatcher rd = getServletContext().getRequestDispatcher("/"); rd.forward(request, response); return; } else { session.setAttribute("errors", ""); } // will contain all the inputs for the current workflow Map<String, String> portinputData = new HashMap<String, String>(); // Use this for a list. List<Map<String, String>> inputList = new ArrayList<Map<String, String>>(); int currentDepth = 0; for (WorkflowInput currentInput : currentWorkflow.getInputs()) { int counter = 0; String currentName = currentInput.getName(); String currentNamePrefixed = "workflow" + j + currentName; currentDepth = currentInput.getDepth(); // get the current input value String currentValue = htmlFormItems.get(currentNamePrefixed); // if the inputs are just simple values if (currentDepth == 0) { // put the value into taverna-specific map portinputData.put(currentName, currentValue); // if the inputs are a list of values } else if (currentDepth > 0) { int i = 0; portinputData.put(currentName, currentValue); inputList.add(i, portinputData); while (htmlFormItems.get(currentNamePrefixed + i) != null && !htmlFormItems.get(currentNamePrefixed + i).equals("")) { String additionalValue = htmlFormItems.get(currentNamePrefixed + i); portinputData = new HashMap<String, String>(); // valueList.add(new DataValue(additionalValue)); i++; portinputData.put(currentName, additionalValue); inputList.add(i, portinputData); } } } if (currentDepth == 0) inputList.add(0, portinputData); System.out.println("Size: " + inputList.size()); for (Map<String, String> inputData : inputList) { System.out.println("DS: " + inputData.entrySet()); runID = tavernaRESTClient.createRun(currentWorkflowBytes, user); Map<String, InputPort> inputPorts = runID.getInputPorts(); // convert input values from html form to taverna-specific objects for (Map.Entry<String, String> inputWorkflow : inputData.entrySet()) { runID.getInputPort(inputWorkflow.getKey()).setValue(inputWorkflow.getValue()); //System.out.println("INPUT: " + inputWorkflow.getValue()); } runID.start(); //System.out.println("Run URL: "+ runID.getURI() ); runIDs.add(runID); //System.err.print("Run UUID: "+ runID.getIdentifier() + " STATUS:" + runID.getStatus() ); j++; // wait until all jobs are done for (Run currentRunID : runIDs) { while (currentRunID.isRunning()) { try { duration = System.currentTimeMillis() - startTime; System.out.println( "Waiting for job [" + currentRunID.getIdentifier() + "] to complete (" + (duration / 1000f) + ")" + " STATUS:" + runID.getStatus()); Thread.sleep(1000); } catch (InterruptedException e) { System.out.println("HOPELESS"); } } } // process the outputs int workflowIndex = 0; for (Run currentRunID : runIDs) { // will contain outputs from all ports of the current workflow List<WorkflowOutputPort> workflowOutputPorts = new ArrayList<WorkflowOutputPort>(); if (currentRunID.isFinished()) { System.out.println("Owner: " + currentRunID.isOwner()); // get the outputs of the current job if (currentRunID.isOwner()) { System.out.println("Output state: " + currentRunID.getExitCode()); Map<String, OutputPort> outputPorts = null; if (currentRunID.getOutputPorts() != null) outputPorts = currentRunID.getOutputPorts(); for (Map.Entry<String, OutputPort> outputPort : outputPorts.entrySet()) { WorkflowOutputPort workflowOutPortCurrent = new WorkflowOutputPort(); if (outputPort != null) { if (outputPort.getValue().getDepth() == 0) { workflowOutPortCurrent.setOutput(outputPort.getValue(), false); workflowOutputPorts.add(workflowOutPortCurrent); } else { System.out.println("outputName : " + outputPort.getKey()); workflowOutPortCurrent.setOutput(outputPort.getValue(), currentRunID, outputPort.getKey(), outputPort.getValue().getDepth()); workflowOutputPorts.add(workflowOutPortCurrent); } } } currentRunID.delete(); } } allOutputs.add(workflowOutputPorts); workflowIndex++; } } } session.setAttribute("allOutputs", allOutputs); request.setAttribute("round2", "round2"); duration = System.currentTimeMillis() - startTime; System.out.println("Jobs took " + (duration / 1000f) + " seconds"); // get back to JSP RequestDispatcher rd = getServletContext().getRequestDispatcher("/"); rd.forward(request, response); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } }