List of usage examples for javax.servlet RequestDispatcher forward
public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException;
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.listing.DataPropertyHierarchyListingController.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) { if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTIONS)) { return;/*from ww w . ja v a 2s. c o m*/ } VitroRequest vrequest = new VitroRequest(request); try { dpDao = vrequest.getAssertionsWebappDaoFactory().getDataPropertyDao(); vcDao = vrequest.getAssertionsWebappDaoFactory().getVClassDao(); pgDao = vrequest.getAssertionsWebappDaoFactory().getPropertyGroupDao(); dDao = vrequest.getAssertionsWebappDaoFactory().getDatatypeDao(); ArrayList<String> results = new ArrayList<String>(); results.add("XX"); // column 1 results.add("property"); // column 2 results.add("domain vclass"); // column 3 results.add("range vclass"); // column 4 results.add("group"); // column 5 results.add("display tier"); // column 6 results.add("display level"); // column 7 results.add("update level"); // column 8 results.add("XX"); // column 9 String ontologyUri = request.getParameter("ontologyUri"); String startPropertyUri = request.getParameter("propertyUri"); List<DataProperty> roots = null; if (startPropertyUri != null) { roots = new LinkedList<DataProperty>(); roots.add(dpDao.getDataPropertyByURI(startPropertyUri)); } else { roots = dpDao.getRootDataProperties(); if (roots != null) { Collections.sort(roots); } } if (roots != null) { Iterator<DataProperty> rootIt = roots.iterator(); if (!rootIt.hasNext()) { DataProperty dp = new DataProperty(); dp.setURI(ontologyUri + "fake"); String notFoundMessage = "<strong>No data properties found.</strong>"; dp.setName(notFoundMessage); dp.setName(notFoundMessage); results.addAll(addDataPropertyDataToResultsList(dp, 0, ontologyUri)); } else { while (rootIt.hasNext()) { DataProperty root = rootIt.next(); if ((ontologyUri == null) || ((ontologyUri != null) && (root.getNamespace() != null) && (ontologyUri.equals(root.getNamespace())))) { ArrayList childResults = new ArrayList(); addChildren(root, childResults, 0, ontologyUri); results.addAll(childResults); } } } } request.setAttribute("results", results); request.setAttribute("columncount", NUM_COLS); request.setAttribute("suppressquery", "true"); request.setAttribute("title", "Data Property Hierarchy"); request.setAttribute("bodyJsp", Controllers.HORIZONTAL_JSP); // new way of adding more than one button List<ButtonForm> buttons = new ArrayList<ButtonForm>(); HashMap<String, String> newPropParams = new HashMap<String, String>(); newPropParams.put("controller", "Dataprop"); ButtonForm newPropButton = new ButtonForm(Controllers.RETRY_URL, "buttonForm", "Add new data property", newPropParams); buttons.add(newPropButton); HashMap<String, String> allPropParams = new HashMap<String, String>(); String temp; if ((temp = vrequest.getParameter("ontologyUri")) != null) { allPropParams.put("ontologyUri", temp); } ButtonForm allPropButton = new ButtonForm("listDatatypeProperties", "buttonForm", "show all data properties", allPropParams); buttons.add(allPropButton); request.setAttribute("topButtons", buttons); /* request.setAttribute("horizontalJspAddButtonUrl", Controllers.RETRY_URL); request.setAttribute("horizontalJspAddButtonText", "Add new data property"); request.setAttribute("horizontalJspAddButtonControllerParam", "Property"); */ RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); try { rd.forward(request, response); } catch (Exception e) { e.printStackTrace(); } } catch (Throwable t) { t.printStackTrace(); } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.jena.JenaCsv2RdfController.java
private void forwardToFileUploadError(String errrorMsg, HttpServletRequest req, HttpServletResponse response) throws ServletException { VitroRequest vreq = new VitroRequest(req); req.setAttribute("title", "CSV to RDF Error "); req.setAttribute("bodyJsp", "/jsp/fileUploadError.jsp"); req.setAttribute("errors", errrorMsg); RequestDispatcher rd = req.getRequestDispatcher(Controllers.BASIC_JSP); req.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + vreq.getAppBean().getThemeDir() + "css/edit.css\"/>"); try {/*from w w w .ja v a2 s . co m*/ rd.forward(req, response); } catch (IOException e1) { log.error(e1); throw new ServletException(e1); } return; }
From source file:org.apache.roller.planet.ui.rendering.MultiPlanetRequestMapper.java
public boolean handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // kinda silly, but we need to keep track of whether or not the url had // a trailing slash so that we can act accordingly boolean trailingSlash = false; String planetHandle = null;// ww w . j a v a2s. com String planetContext = null; String groupHandle = null; String groupContext = null; String extraRequestData = null; log.debug("evaluating [" + request.getRequestURI() + "]"); // figure out potential planet handle String uri = request.getRequestURI(); String pathInfo = null; if (uri != null && uri.trim().length() > 1) { if (request.getContextPath() != null) uri = uri.substring(request.getContextPath().length()); // strip off the leading slash uri = uri.substring(1); // strip off trailing slash if needed if (uri.endsWith("/")) { uri = uri.substring(0, uri.length() - 1); trailingSlash = true; } if (uri.indexOf("/") != -1) { planetHandle = uri.substring(0, uri.indexOf("/")); pathInfo = uri.substring(uri.indexOf("/") + 1); } else { planetHandle = uri; } } log.debug("potential planet handle = " + planetHandle); // check if it's a valid planet handle if (restricted.contains(planetHandle) || !this.isPlanet(planetHandle)) { log.debug("SKIPPED " + planetHandle); return false; } log.debug("PLANET_URL " + request.getServletPath()); // parse the rest of the url if (pathInfo != null) { // parse the next portion of the url // we expect <context>/<groupHandle>/<groupContext>/<extra>/<info> String[] urlPath = pathInfo.split("/", 4); planetContext = urlPath[0]; if (urlPath.length == 2) { groupHandle = urlPath[1]; } else if (urlPath.length == 3) { groupHandle = urlPath[1]; groupContext = urlPath[2]; } else if (urlPath.length == 4) { groupHandle = urlPath[1]; groupContext = urlPath[2]; extraRequestData = urlPath[3]; } } // special handling for trailing slash issue // we need this because by http standards the urls /foo and /foo/ are // supposed to be considered different, so we must enforce that if ((planetContext == null && !trailingSlash) || (groupHandle != null && groupContext == null && !trailingSlash)) { // this means someone referred to a planet or group index page // with the shortest form of url /<planet> or /<planet>/group/<group> // and we need to add a slash to the url and redirect String redirectUrl = request.getRequestURI() + "/"; if (request.getQueryString() != null) { redirectUrl += "?" + request.getQueryString(); } response.sendRedirect(redirectUrl); return true; } else if (groupContext != null && trailingSlash) { // this means that someone has accessed a url and included a // trailing slash, like /<planet>/group/<group>/feed/atom/ which is // not supported, so we need to offer up a 404 Not Found response.sendError(HttpServletResponse.SC_NOT_FOUND); return true; } // calculate forward url String forwardUrl = calculateForwardUrl(request, planetHandle, planetContext, groupHandle, groupContext, extraRequestData); // if we don't have a forward url then the request was invalid somehow if (forwardUrl == null) { return false; } // dispatch to forward url log.debug("forwarding to " + forwardUrl); RequestDispatcher dispatch = request.getRequestDispatcher(forwardUrl); dispatch.forward(request, response); // we dealt with this request ourselves, so return "true" return true; }
From source file:nu.kelvin.jfileshare.ajax.FileReceiverServlet.java
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { HttpSession session = req.getSession(); UserItem currentUser = (UserItem) session.getAttribute("user"); if (currentUser != null && ServletFileUpload.isMultipartContent(req)) { Conf conf = (Conf) getServletContext().getAttribute("conf"); // keep files of up to 10 MiB in memory 10485760 FileItemFactory factory = new DiskFileItemFactory(10485760, new File(conf.getPathTemp())); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(conf.getFileSizeMax()); // set file upload progress listener FileUploadListener listener = new FileUploadListener(); session.setAttribute("uploadListener", listener); upload.setProgressListener(listener); File tempFile = File.createTempFile(String.format("%05d-", currentUser.getUid()), null, new File(conf.getPathTemp())); tempFile.deleteOnExit();//from w w w .j a va2 s. c o m try { FileItem file = new FileItem(); /* iterate over all uploaded items */ FileItemIterator it = upload.getItemIterator(req); FileOutputStream filestream = null; while (it.hasNext()) { FileItemStream item = it.next(); String name = item.getFieldName(); InputStream instream = item.openStream(); DigestOutputStream outstream = null; if (item.isFormField()) { String value = Streams.asString(instream); // logger.info(name + " : " + value); /* not the file upload. Maybe the password field? */ if (name.equals("password") && !value.equals("")) { logger.info("Uploaded file has password set"); file.setPwPlainText(value); } instream.close(); } else { // This is the file you're looking for file.setName(item.getName()); file.setType( item.getContentType() == null ? "application/octet-stream" : item.getContentType()); file.setUid(currentUser.getUid()); try { filestream = new FileOutputStream(tempFile); MessageDigest md = MessageDigest.getInstance("MD5"); outstream = new DigestOutputStream(filestream, md); long filesize = IOUtils.copyLarge(instream, outstream); if (filesize == 0) { throw new Exception("File is empty."); } md = outstream.getMessageDigest(); file.setMd5sum(toHex(md.digest())); file.setSize(filesize); } finally { if (outstream != null) { try { outstream.close(); } catch (IOException ignored) { } } if (filestream != null) { try { filestream.close(); } catch (IOException ignored) { } } if (instream != null) { try { instream.close(); } catch (IOException ignored) { } } } } } /* All done. Save the new file */ if (conf.getDaysFileExpiration() != 0) { file.setDaysToKeep(conf.getDaysFileExpiration()); } if (file.create(ds, req.getRemoteAddr())) { File finalFile = new File(conf.getPathStore(), Integer.toString(file.getFid())); tempFile.renameTo(finalFile); logger.log(Level.INFO, "User {0} storing file \"{1}\" in the filestore", new Object[] { currentUser.getUid(), file.getName() }); req.setAttribute("msg", "File <strong>\"" + Helpers.htmlSafe(file.getName()) + "\"</strong> uploaded successfully. <a href='" + req.getContextPath() + "/file/edit/" + file.getFid() + "'>Click here to edit file</a>"); req.setAttribute("javascript", "parent.uploadComplete('info');"); } else { req.setAttribute("msg", "Unable to contact the database"); req.setAttribute("javascript", "parent.uploadComplete('critical');"); } } catch (SizeLimitExceededException e) { tempFile.delete(); req.setAttribute("msg", "File is too large. The maximum size of file uploads is " + FileItem.humanReadable(conf.getFileSizeMax())); req.setAttribute("javascript", "parent.uploadComplete('warning');"); } catch (FileUploadException e) { tempFile.delete(); req.setAttribute("msg", "Unable to upload file"); req.setAttribute("javascript", "parent.uploadComplete('warning');"); } catch (Exception e) { tempFile.delete(); req.setAttribute("msg", "Unable to upload file. ".concat(e.getMessage() == null ? "" : e.getMessage())); req.setAttribute("javascript", "parent.uploadComplete('warning');"); } finally { session.setAttribute("uploadListener", null); } ServletContext app = getServletContext(); RequestDispatcher disp = app.getRequestDispatcher("/templates/AjaxDummy.jsp"); disp.forward(req, resp); } }
From source file:com.mockey.ui.HomeServlet.java
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String action = req.getParameter(API_CONFIGURATION_PARAMETER_ACTION); String type = req.getParameter(API_CONFIGURATION_PARAMETER_TYPE); if (action != null && "init".equals(action)) { // Flush - clean slate. IMockeyStorage store = StorageRegistry.MockeyStorage; JSONObject jsonResultObject = new JSONObject(); // Load with local file. String fileName = req.getParameter("file"); Boolean transientState = new Boolean(true); try {//from w w w . j a v a 2s .c o m transientState = new Boolean( req.getParameter(API_CONFIGURATION_PARAMETER_ACTION_VALUE_TRANSIENT_STATE)); store.setReadOnlyMode(transientState); logger.debug("Read only mode? " + transientState); } catch (Exception e) { } try { File f = new File(fileName); if (f.exists()) { // Slurp it up and initialize definitions. FileInputStream fstream = new FileInputStream(f); BufferedReader br = new BufferedReader( new InputStreamReader(fstream, Charset.forName(HTTP.UTF_8))); StringBuffer inputString = new StringBuffer(); // Read File Line By Line String strLine = null; // READ FIRST while ((strLine = br.readLine()) != null) { // Print the content on the console inputString.append(new String(strLine.getBytes(HTTP.UTF_8))); } // DELETE SECOND store.deleteEverything(); MockeyXmlFileManager reader = new MockeyXmlFileManager(); reader.loadConfigurationWithXmlDef(inputString.toString()); logger.info("Loaded definitions from " + fileName); jsonResultObject.put(SUCCESS, "Loaded definitions from " + fileName); jsonResultObject.put(API_CONFIGURATION_PARAMETER_FILE, fileName); } else { logger.info(fileName + " does not exist. doing nothing."); jsonResultObject.put(FAIL, fileName + " does not exist. doing nothing."); } } catch (Exception e) { logger.debug("Unable to load service definitions with name: '" + fileName + "'", e); try { jsonResultObject.put(FAIL, "Unable to load service definitions with name: '" + fileName + "'"); } catch (Exception ef) { logger.error("Unable to produce a JSON response.", e); } } // OK, return JSON or HTML? if (type != null && type.trim().equalsIgnoreCase("json")) { resp.setContentType("application/json;"); PrintWriter out = resp.getWriter(); JSONObject jsonResponseObject = new JSONObject(); try { jsonResponseObject.put("result", jsonResultObject); } catch (JSONException e) { logger.error("Unable to produce a JSON result.", e); } out.println(jsonResponseObject.toString()); return; } else { String contextRoot = req.getContextPath(); resp.sendRedirect(Url.getContextAwarePath("/home", contextRoot)); return; } } else if (action != null && "deleteAllServices".equals(action)) { // Flush - clean slate. IMockeyStorage store = StorageRegistry.MockeyStorage; store.deleteEverything(); if (type != null && type.trim().equalsIgnoreCase("json")) { resp.setContentType("application/json;"); PrintWriter out = resp.getWriter(); JSONObject jsonResponseObject = new JSONObject(); JSONObject jsonObject = new JSONObject(); try { jsonObject.put(SUCCESS, "All is deleted. You have a clean slate. Enjoy."); jsonResponseObject.put("result", jsonObject); } catch (JSONException e) { logger.error("Unable to produce a JSON result.", e); } out.println(jsonResponseObject.toString()); return; } else { String contextRoot = req.getContextPath(); resp.sendRedirect(Url.getContextAwarePath("/home", contextRoot)); return; } } req.setAttribute("services", Util.orderAlphabeticallyByServiceName(store.getServices())); req.setAttribute("plans", Util.orderAlphabeticallyByServicePlanName(store.getServicePlans())); RequestDispatcher dispatch = req.getRequestDispatcher("home.jsp"); dispatch.forward(req, resp); }
From source file:dbaccess.servlets.LookupServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w w w .j av a 2s . co m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // extract request parameters to a user data bean using // apache BeanUtils UserData userData = new UserData(); BookData bookData = new BookData(); try { BeanUtils.populate(userData, request.getParameterMap()); BeanUtils.populate(bookData, request.getParameterMap()); String nextPage = null; // set up the bean as request parameter request.setAttribute("userData", userData); request.setAttribute("bookData", bookData); // check the operation and dispatch accordingly if (request.getParameter("lookup") != null) { List<User> results = null; if (!"".equals(userData.getId())) { // lookup by id results = getUserById(em, userData); } else if (!"".equals(userData.getName())) { // lookup by name results = getUsersByName(em, userData); } else if (!"".equals(userData.getBirthdate())) { // lookup by birthdate results = getUsersByBirthDate(em, userData); } if (results != null) { // users have been found request.setAttribute("results", results); //dispatch to JSP for displaying results nextPage = "/userResults.jsp"; } else { // users not found // dispatch to error page nextPage = "/lookupError.jsp"; } } else if (request.getParameter("add") != null) { if (userData.isComplete()) { if (DBHelper.addUser(em, utx, userData)) { nextPage = "/successfulAdd.jsp"; } else { nextPage = "/failedAdd.jsp"; } } else { nextPage = "/failedAddIncomplete.jsp"; } } else if (request.getParameter("lookupBook") != null) { List<Book> results = null; if (!"".equals(bookData.getId())) { // lookup by id results = getBookById(em, bookData); } else if (!"".equals(bookData.getName())) { // lookup by name results = getBookByName(em, bookData); } else if (!"".equals(bookData.getAuthor())) { // lookup by author results = getBookByAuthor(em, bookData); } else if (!"".equals(bookData.getDescription())) { // lookup by description results = getBookByDescription(em, bookData); } else if (!"".equals(bookData.getDescription())) { // lookup by price results = getBookByPrice(em, bookData); } else if (!"".equals(bookData.getType())) { // lookup by type results = getBookByType(em, bookData); } if (results != null) { // users have been found request.setAttribute("results", results); //dispatch to JSP for displaying results nextPage = "/bookResults.jsp"; } else { // users not found // dispatch to error page nextPage = "/lookupErrorBook.jsp"; } } else if (request.getParameter("addBook") != null) { if (bookData.isComplete()) { if (DBHelper.addBook(em, utx, bookData)) { nextPage = "/successfulAddBook.jsp"; } else { nextPage = "/failedAddBook.jsp"; } } else { nextPage = "/failedAddIncompleteBook.jsp"; } } else if (request.getParameter("deleteBook") != null) { if (DBHelper.deleteBook(em, utx, bookData.getId())) { nextPage = "/successfulDeleteBook.jsp"; } else { nextPage = "/failedDeleteBook.jsp"; } } RequestDispatcher dispatcher = request.getRequestDispatcher(nextPage); dispatcher.forward(request, response); } catch (IllegalAccessException | InvocationTargetException | ServletException | IOException ex) { } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.listing.ObjectPropertyHierarchyListingController.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) { if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTIONS)) { return;// ww w.j a v a2s. co m } VitroRequest vrequest = new VitroRequest(request); try { opDao = vrequest.getAssertionsWebappDaoFactory().getObjectPropertyDao(); vcDao = vrequest.getAssertionsWebappDaoFactory().getVClassDao(); pgDao = vrequest.getAssertionsWebappDaoFactory().getPropertyGroupDao(); ArrayList<String> results = new ArrayList<String>(); results.add("XX"); // column 1 results.add("property"); // column 2 results.add("domain vclass"); // column 3 results.add("range vclass"); // column 4 results.add("group"); // column 5 results.add("display tier"); // column 6 results.add("display level"); // column 7 results.add("update level"); // column 8 results.add("XX"); // column 10 String ontologyUri = request.getParameter("ontologyUri"); String startPropertyUri = request.getParameter("propertyUri"); List<ObjectProperty> roots = null; if (startPropertyUri != null) { roots = new LinkedList<ObjectProperty>(); ObjectProperty op = opDao.getObjectPropertyByURI(startPropertyUri); if (op == null) { op = new ObjectProperty(); op.setURI(startPropertyUri); } roots.add(op); } else { roots = opDao.getRootObjectProperties(); if (roots != null) { Collections.sort(roots, new ObjectPropertyAlphaComparator()); // sorts by domain public } } if (roots != null) { Iterator<ObjectProperty> rootIt = roots.iterator(); if (!rootIt.hasNext()) { ObjectProperty op = new ObjectProperty(); op.setURI(ontologyUri + "fake"); String notFoundMessage = "<strong>No object properties found.</strong>"; op.setDomainPublic(notFoundMessage); results.addAll(addObjectPropertyDataToResultsList(op, 0, ontologyUri)); } else { while (rootIt.hasNext()) { ObjectProperty root = rootIt.next(); if ((ontologyUri == null) || ((ontologyUri != null) && (root.getNamespace() != null) && (ontologyUri.equals(root.getNamespace())))) { ArrayList childResults = new ArrayList(); addChildren(root, childResults, 0, ontologyUri); results.addAll(childResults); } } } } request.setAttribute("results", results); request.setAttribute("columncount", NUM_COLS); request.setAttribute("suppressquery", "true"); request.setAttribute("title", "Object Property Hierarchy"); request.setAttribute("bodyJsp", Controllers.HORIZONTAL_JSP); // new way of adding more than one button List<ButtonForm> buttons = new ArrayList<ButtonForm>(); HashMap<String, String> newPropParams = new HashMap<String, String>(); newPropParams.put("controller", "Property"); ButtonForm newPropButton = new ButtonForm(Controllers.RETRY_URL, "buttonForm", "Add new object property", newPropParams); buttons.add(newPropButton); HashMap<String, String> allPropParams = new HashMap<String, String>(); String temp; if ((temp = vrequest.getParameter("ontologyUri")) != null) { allPropParams.put("ontologyUri", temp); } ButtonForm allPropButton = new ButtonForm("listPropertyWebapps", "buttonForm", "show all object properties", allPropParams); buttons.add(allPropButton); request.setAttribute("topButtons", buttons); /* request.setAttribute("horizontalJspAddButtonUrl", Controllers.RETRY_URL); request.setAttribute("horizontalJspAddButtonText", "Add new object property"); request.setAttribute("horizontalJspAddButtonControllerParam", "Property"); */ RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); try { rd.forward(request, response); } catch (Exception e) { e.printStackTrace(); } } catch (Throwable t) { t.printStackTrace(); } }
From source file:com.jaeksoft.searchlib.web.ServletTransaction.java
public void forward(String path) throws ServletException { RequestDispatcher dispatcher = servlet.getServletContext().getRequestDispatcher(path); try {//from www .j a v a 2 s.c o m dispatcher.forward(request, response); } catch (javax.servlet.ServletException e) { throw new ServletException(e); } catch (IOException e) { throw new ServletException(e); } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.jena.RDFUploadFormController.java
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) { if (!isAuthorizedToDisplayPage(request, response, SimplePermission.USE_ADVANCED_DATA_TOOLS_PAGES.ACTION)) { return;// w ww . j av a2s . co m } VitroRequest vreq = new VitroRequest(request); RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); request.setAttribute("bodyJsp", "/templates/edit/specific/upload_rdf.jsp"); request.setAttribute("title", "Ingest RDF Data"); request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + vreq.getAppBean().getThemeDir() + "css/edit.css\"/>"); 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:mashups.eventpub.EventPublisherServlet.java
/** * Publish all events to Calendar and/or Base * * @param request The request /*from w w w. j a va 2 s.co m*/ * @param response The response */ @SuppressWarnings("unchecked") private void processPublishEvents(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { EventPublisher ep = new EventPublisher(); ep.setFieldMap((SpreadsheetCustomFieldMap) request.getSession().getAttribute(SESSION_ATTR_FIELD_MAP)); try { ep.setSsAuthSubToken((String) request.getSession().getAttribute(SESSION_ATTR_SS_AUTH_TOKEN), false); } catch (EPAuthenticationException e) { System.err.println("Authentication exception: " + e.getMessage()); } LinkedList<Event> eventList = (LinkedList<Event>) request.getSession() .getAttribute(SESSION_ATTR_EVENTS_TO_PUBLISH); if (request.getParameter("calendar") != null && "checked".equals(request.getParameter("calendar"))) { String calUsername = config.getString("calendar.username"); String calPassword = config.getString("calendar.password"); String calUrl = config.getString("calendar.url"); ep.setCalUsernamePassword(calUsername, calPassword); ep.setCalUrl(calUrl); ep.publishEventsToCalendar(eventList); } if (request.getParameter("base") != null && "checked".equals(request.getParameter("base"))) { String baseUsername = config.getString("gbase.username"); String basePassword = config.getString("gbase.password"); ep.setBaseUsernamePassword(baseUsername, basePassword); ep.publishEventsToBase(eventList); } javax.servlet.RequestDispatcher dispatcher = getServletContext() .getRequestDispatcher("/WEB-INF/jsp/outputPublishingResults.jsp"); dispatcher.forward(request, response); }