List of usage examples for javax.servlet RequestDispatcher forward
public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException;
From source file:org.zkoss.zkgrails.ZKGrailsPageFilter.java
protected void applyDecorator(Page page, Decorator decorator, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String uriPath = decorator.getURIPath(); if (uriPath != null && uriPath.endsWith(".gsp")) { request.setAttribute(PAGE, page); detectContentTypeFromPage(page, response); RequestDispatcher rd = request.getRequestDispatcher(decorator.getURIPath()); if (!response.isCommitted()) { if (LOG.isDebugEnabled()) { LOG.debug("Rendering layout using forward: " + decorator.getURIPath()); }// ww w . j a v a 2 s . c om rd.forward(request, response); } else { if (LOG.isDebugEnabled()) { LOG.debug("Rendering layout using include: " + decorator.getURIPath()); } request.setAttribute(GrailsApplicationAttributes.GSP_TO_RENDER, decorator.getURIPath()); rd.include(request, response); request.removeAttribute(GrailsApplicationAttributes.GSP_TO_RENDER); } // set the headers specified as decorator init params while (decorator.getInitParameterNames().hasNext()) { String initParam = (String) decorator.getInitParameterNames().next(); if (initParam.startsWith("header.")) { response.setHeader(initParam.substring(initParam.indexOf('.')), decorator.getInitParameter(initParam)); } } request.removeAttribute(PAGE); } else { super.applyDecorator(page, decorator, request, response); } }
From source file:eu.impact_project.wsclient.SOAPresults.java
/** * Loads the user values/files and sends them to the web service. Files are * encoded to Base64. Stores the resulting message in the session and the * resulting files on the server./*from w w w. jav a2 s . c o m*/ */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { OutputStream outStream = null; BufferedInputStream bis = null; user = request.getParameter("user"); pass = request.getParameter("pass"); try { HttpSession session = request.getSession(true); String folder = session.getServletContext().getRealPath("/"); if (!folder.endsWith("/")) { folder = folder + "/"; } Properties props = new Properties(); InputStream stream = new URL("file:" + folder + "config.properties").openStream(); props.load(stream); stream.close(); boolean loadDefault = Boolean.parseBoolean(props.getProperty("loadDefaultWebService")); boolean supportFileUpload = Boolean.parseBoolean(props.getProperty("supportFileUpload")); boolean oneResultFile = Boolean.parseBoolean(props.getProperty("oneResultFile")); String defaultFilePrefix = props.getProperty("defaultFilePrefix"); SoapService serviceObject = (SoapService) session.getAttribute("serviceObject"); SoapOperation operation = null; if (supportFileUpload) { // stores all the strings and encoded files from the html form Map<String, String> htmlFormItems = new HashMap<String, String>(); FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List /* FileItem */ items = upload.parseRequest(request); // Process the uploaded items Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); // a normal string field if (item.isFormField()) { htmlFormItems.put(item.getFieldName(), item.getString()); // uploaded file } else { // encode the uploaded file to base64 String currentAttachment = new String(Base64.encode(item.get())); htmlFormItems.put(item.getFieldName(), currentAttachment); } } // get the chosen WSDL operation String operationName = htmlFormItems.get("operationName"); operation = serviceObject.getOperation(operationName); for (SoapInput input : operation.getInputs()) { input.setValue(htmlFormItems.get(input.getName())); } } else { // get the chosen WSDL operation String operationName = request.getParameter("operationName"); operation = serviceObject.getOperation(operationName); for (SoapInput input : operation.getInputs()) { String[] soapInputValues = request.getParameterValues(input.getName()); input.clearValues(); for (String value : soapInputValues) { input.addValue(value); } } } List<SoapOutput> outs = operation.execute(user, pass); String soapResponse = operation.getResponse(); String htmlResponse = useXslt(soapResponse, "/SoapToHtml.xsl"); session.setAttribute("htmlResponse", htmlResponse); session.setAttribute("soapResponse", soapResponse); // for giving the file names back to the JSP List<String> fileNames = new ArrayList<String>(); // process possible attachments in the response List<SoapAttachment> attachments = operation.getReceivedAttachments(); int i = 0; for (SoapAttachment attachment : attachments) { // path to the server directory String serverPath = getServletContext().getRealPath("/"); if (!serverPath.endsWith("/")) { serverPath = folder + "/"; } // construct the file name for the attachment String fileEnding = ""; String contentType = attachment.getContentType(); System.out.println("content type: " + contentType); if (contentType.equals("image/gif")) { fileEnding = ".gif"; } else if (contentType.equals("image/jpeg")) { fileEnding = ".jpg"; } else if (contentType.equals("image/tiff")) { fileEnding = ".tif"; } else if (contentType.equals("application/vnd.ms-excel")) { fileEnding = ".xlsx"; } String fileName = loadDefault ? defaultFilePrefix : "attachedFile"; String counter = oneResultFile ? "" : i + ""; String attachedFileName = fileName + counter + fileEnding; // store the attachment into the file File file = new File(serverPath + attachedFileName); outStream = new FileOutputStream(file); InputStream inStream = attachment.getInputStream(); bis = new BufferedInputStream(inStream); int bufSize = 1024 * 8; byte[] bytes = new byte[bufSize]; int count = bis.read(bytes); while (count != -1 && count <= bufSize) { outStream.write(bytes, 0, count); count = bis.read(bytes); } if (count != -1) { outStream.write(bytes, 0, count); } outStream.close(); bis.close(); fileNames.add(attachedFileName); i++; } // pass the file names to JSP request.setAttribute("fileNames", fileNames); request.setAttribute("round3", "round3"); // get back to JSP RequestDispatcher rd = getServletContext().getRequestDispatcher("/interface.jsp"); rd.forward(request, response); } catch (Exception e) { logger.error("Exception", e); e.printStackTrace(); } finally { if (outStream != null) { outStream.close(); } if (bis != null) { bis.close(); } } }
From source file:controller.uploadPergunta9.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w .j a v a 2 s. c om * * @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 { String idLocal = (String) request.getParameter("idLocal"); String idModelo = (String) request.getParameter("idModelo"); String expressaoModelo = (String) request.getParameter("expressaoModelo"); String nomeAutorModelo = (String) request.getParameter("nomeAutorModelo"); String equacaoAjustada = (String) request.getParameter("equacaoAjustada"); String idEquacaoAjustada = (String) request.getParameter("idEquacaoAjustada"); String name = ""; //process only if its multipart content if (ServletFileUpload.isMultipartContent(request)) { try { List<FileItem> multiparts = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request); for (FileItem item : multiparts) { if (!item.isFormField()) { name = new File(item.getName()).getName(); // item.write( new File(UPLOAD_DIRECTORY + File.separator + name)); item.write(new File(AbsolutePath + File.separator + name)); } } //File uploaded successfully request.setAttribute("message", "File Uploaded Successfully"); } catch (Exception ex) { request.setAttribute("message", "File Upload Failed due to " + ex); } } else { request.setAttribute("message", "Sorry this Servlet only handles file upload request"); } equacaoAjustada = equacaoAjustada.replace("+", "%2B"); expressaoModelo = expressaoModelo.replace("+", "%2B"); RequestDispatcher view = getServletContext() .getRequestDispatcher("/novoLocalPergunta9?id=" + idLocal + "&nomeArquivo=" + name + "&idModelo=" + idModelo + "&equacaoAjustada=" + equacaoAjustada + "&expressaoModelo=" + expressaoModelo + "&nomeAutorModelo=" + nomeAutorModelo + "&idEquacaoAjustada=" + idEquacaoAjustada); view.forward(request, response); // request.getRequestDispatcher("/novoLocalPergunta3?id="+idLocal+"&fupload=1&nomeArquivo="+name).forward(request, response); // request.getRequestDispatcher("/novoLocalPergunta4?id="+idLocal+"&nomeArquivo="+name).forward(request, response); }
From source file:org.deegree.test.gui.StressTestController.java
private void doStep1(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String capab = request.getParameter("capabilities"); request.getSession().setAttribute("capab", capab); RequestDispatcher dispatcher = request.getRequestDispatcher("/wpvs_params.jsp"); dispatcher.forward(request, response); }
From source file:acoli.controller.Controller.java
/** * * @param request/* w ww.j a v a2 s. c om*/ * @param response * @throws ServletException * @throws IOException * @throws FileNotFoundException */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, FileNotFoundException { // Get servlet context. ServletContext servletContext = this.getServletConfig().getServletContext(); String path = servletContext.getRealPath("/"); //System.out.println(path); // Previously used way to obtain servlet context doesn't work. //ServletContext context = request.getServletContext(); //String path = context.getRealPath("/"); //System.out.println("ServletContext.getRealPath():" + path + "<--"); String forward = ""; // Get a map of the request parameters @SuppressWarnings("unchecked") Map parameters = request.getParameterMap(); if (parameters.containsKey("grammar")) { HttpSession session = request.getSession(false); String absoluteUnzippedGrammarDir = (String) session.getAttribute("absoluteUnzippedGrammarDir"); //System.out.println("Uploaded file to analyze: " + absoluteUnzippedGrammarDir); // User-selected port. String javaport = (String) request.getParameter("javaport"); System.out.println("User selected port: " + javaport); String traleport = String.valueOf((Integer.parseInt(javaport) - 1000)); // Check if these ports are already in use // if so, kill the grammar in the corresponding directory and start a new one. if (portAvailable(Integer.parseInt(javaport)) && portAvailable(Integer.parseInt(traleport))) { System.out.println("Both javaport/traleport: " + javaport + "/" + traleport + " available!"); } else { // Java port not free. if (!portAvailable(Integer.parseInt(javaport))) { System.out.println("Port: " + javaport + " not available!"); // Get the grammar directory that is running on this port and kill it. if (portToGrammarFolderMappings.containsKey(javaport)) { String grammarDirToKill = portToGrammarFolderMappings.get(javaport); // Stop grammar. runBashScript(path, "./single_grammar_stop.sh", grammarDirToKill, ""); } else { killProcessID(path, "./free_java_port.sh", javaport); } } // Trale port not free. if (!portAvailable(Integer.parseInt(traleport))) { killProcessID(path, "./free_sicstus_port.sh", traleport); } } // Generate port-specific files // which will be redirected by the script later. PrintWriter w = new PrintWriter(new File(absoluteUnzippedGrammarDir + "/" + "javaserverport.txt")); w.write(javaport); w.flush(); w.close(); w = new PrintWriter(new File(absoluteUnzippedGrammarDir + "/" + "traleserverstart.pl")); w.write("trale_server_start(" + traleport + ").\n"); // 1000 port ids less than the java id. w.flush(); w.close(); // Copy wtx.pl and tokenization.pl into the grammar directory. File tokenizationFile = new File(path + "/resources/servertrale_files/tokenization.pl"); File wtxFile = new File(path + "/resources/servertrale_files/wtx.pl"); //System.out.println("tokenizationFile: " + tokenizationFile.getAbsolutePath()); //System.out.println("wtxFile: " + wtxFile.getAbsolutePath()); File destinationDir = new File(absoluteUnzippedGrammarDir + "/"); //System.out.println("destinationDir: " + absoluteUnzippedGrammarDir); FileUtils.copyFileToDirectory(tokenizationFile, destinationDir); FileUtils.copyFileToDirectory(wtxFile, destinationDir); // Start grammar. // Check webtrale version from user selection. String labelVersion = (String) request.getParameter("webtraleVersion"); System.out.println("User selected label version: " + labelVersion); switch (labelVersion) { case "webtralePS94": runBashScript(path, "./single_grammar_start.sh", absoluteUnzippedGrammarDir, "webtrale_green_labels.jar"); break; case "webtraleAprilLabels": // April labels. runBashScript(path, "./single_grammar_start.sh", absoluteUnzippedGrammarDir, "webtrale_green_aprillabels.jar"); break; case "webtraleMayLabels": // May labels. runBashScript(path, "./single_grammar_start.sh", absoluteUnzippedGrammarDir, "webtrale_green_maylabels.jar"); break; case "webtraleJuneLabels": // June labels. runBashScript(path, "./single_grammar_start.sh", absoluteUnzippedGrammarDir, "webtrale_green_junelabels.jar"); break; default: // Standard labels. runBashScript(path, "./single_grammar_start.sh", absoluteUnzippedGrammarDir, "webtrale_green_nolabels.jar"); break; } portToGrammarFolderMappings.put(javaport, absoluteUnzippedGrammarDir); session.setAttribute("javaport", javaport); System.out.println("Used ports and grammar directories: " + portToGrammarFolderMappings + "\n"); forward = GRAMMAR_JSP; } else if (parameters.containsKey("run")) { forward = RUN_JSP; } else if (parameters.containsKey("admin")) { System.out.println("Accessing grammar admin."); // Check which ports are still non-available. TreeMap<String, String> tmpMap = new TreeMap<>(); for (String aJavaPort : portToGrammarFolderMappings.keySet()) { if (!portAvailable(Integer.parseInt(aJavaPort))) { tmpMap.put(aJavaPort, portToGrammarFolderMappings.get(aJavaPort)); } } portToGrammarFolderMappings.clear(); portToGrammarFolderMappings = tmpMap; System.out .println("Used ports and grammar directories in admin: " + portToGrammarFolderMappings + "\n"); // only testing. //portToGrammarFolderMappings.put("7001", "/var/lib/tomcat7/webapps/servertrale/resources/uploads/BEBFECC89/posval"); //portToGrammarFolderMappings.put("7002", "/var/lib/tomcat7/webapps/servertrale/resources/uploads/B02CA6BAA/4_Semantics_Raising"); // Save all used ports and directories in this session attribute. HttpSession session = request.getSession(false); String portToGrammarFolderMappingsString = portToGrammarFolderMappings.toString().substring(1, portToGrammarFolderMappings.toString().length() - 1); session.setAttribute("runningGrammars", portToGrammarFolderMappingsString.split("\\, ")); forward = ADMIN_JSP; } // Upload (START PAGE) else { // HttpSession session = request.getSession(false); // String absoluteUnzippedGrammarDir = (String) session.getAttribute("absoluteUnzippedGrammarDir"); // if (absoluteUnzippedGrammarDir != null) { // // Stop grammar. // runBashScript(path, "./single_grammar_stop.sh", absoluteUnzippedGrammarDir); // // Remove this java port from the list of occupied ports. // TreeMap<String, String> tmpMap = new TreeMap<>(); // for(String aJavaPort : portToGrammarFolderMappings.keySet()) { // String aGrammarDir = portToGrammarFolderMappings.get(aJavaPort); // if(aGrammarDir.equals(absoluteUnzippedGrammarDir)) { // // Java port should be removed. So ignore it. // } // else { // tmpMap.put(aJavaPort, absoluteUnzippedGrammarDir); // } // } // portToGrammarFolderMappings.clear(); // portToGrammarFolderMappings = tmpMap; // System.out.println("Used ports and grammar directories: " + portToGrammarFolderMappings + "\n\n"); // // } else { // System.out.println("No grammar to kill."); // } forward = UPLOAD_JSP; } RequestDispatcher view = request.getRequestDispatcher(forward); view.forward(request, response); }
From source file:edu.cornell.mannlib.vitro.webapp.filters.PageRoutingFilter.java
@Override public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain chain) throws IOException, ServletException { ServletContext ctx = filterConfig.getServletContext(); PageDao pageDao = ModelAccess.on(ctx).getWebappDaoFactory().getPageDao(); Map<String, String> urlMappings = pageDao.getPageMappings(); // get URL without hostname or servlet context HttpServletResponse response = (HttpServletResponse) arg1; HttpServletRequest req = (HttpServletRequest) arg0; String path = req.getRequestURI().substring(req.getContextPath().length()); // check for first part of path // ex. /hats/superHat -> /hats Matcher m = urlPartPattern.matcher(path); if (m.matches() && m.groupCount() >= 1) { String path1stPart = m.group(1); String pageUri = urlMappings.get(path1stPart); //try it with a leading slash? if (pageUri == null) pageUri = urlMappings.get("/" + path1stPart); if (pageUri != null && !pageUri.isEmpty()) { log.debug(path + "is a request to a page defined in the display model as " + pageUri); //add the pageUri to the request scope for use by the PageController PageController.putPageUri(req, pageUri); //This will send requests to HomePageController or PageController String controllerName = getControllerToForwardTo(req, pageUri, pageDao); log.debug(path + " is being forwarded to controller " + controllerName); RequestDispatcher rd = ctx.getNamedDispatcher(controllerName); if (rd == null) { log.error(path + " should be forwarded to controller " + controllerName + " but there " + "is no servlet named that defined for the web application in web.xml"); //TODO: what should be done in this case? }//www. j a va 2 s. co m rd.forward(req, response); } else if ("/".equals(path) || path.isEmpty()) { log.debug("url '" + path + "' is being forward to home controller"); RequestDispatcher rd = ctx.getNamedDispatcher(HOME_CONTROLLER_NAME); rd.forward(req, response); } else { doNonDisplayPage(path, arg0, arg1, chain); } } else { doNonDisplayPage(path, arg0, arg1, chain); } }
From source file:cn.vlabs.umt.ui.servlet.login.LoginMethod.java
protected void doForward(String url, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String mappedURL = getThemedJSP(request, url); RequestDispatcher rd = request.getSession().getServletContext().getRequestDispatcher(mappedURL); rd.forward(request, response); }
From source file:agent_update.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// w w w.j av a2 s . 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, FileUploadException { response.setContentType("text/html;charset=UTF-8"); HttpSession hs = request.getSession(); PrintWriter out = response.getWriter(); try { if (hs.getAttribute("user") != null) { Login ln = (Login) hs.getAttribute("user"); System.out.println(ln.getUId()); String fn = ""; String lastn = ""; String un = ""; String state = ""; String city = ""; String area = ""; String e = ""; String ad1 = ""; String ad2 = ""; String num = ""; String p = ""; String des = ""; String cmp = ""; String work = ""; String agentphoto = ""; String agentname = ""; int id = 0; // creates FileItem instances which keep their content in a temporary file on disk FileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); //get the list of all fields from request List<FileItem> fields = upload.parseRequest(request); // iterates the object of list Iterator<FileItem> it = fields.iterator(); //getting objects one by one while (it.hasNext()) { //assigning coming object if list to object of FileItem FileItem fileItem = it.next(); //check whether field is form field or not boolean isFormField = fileItem.isFormField(); if (isFormField) { //get the filed name String fieldName = fileItem.getFieldName(); if (fieldName.equals("fname")) { fn = fileItem.getString(); } else if (fieldName.equals("id")) { id = Integer.parseInt(fileItem.getString()); } else if (fieldName.equals("lname")) { lastn = fileItem.getString(); } else if (fieldName.equals("uname")) { un = fileItem.getString(); } else if (fieldName.equals("state")) { state = fileItem.getString(); } else if (fieldName.equals("city")) { city = fileItem.getString(); } else if (fieldName.equals("area")) { area = fileItem.getString(); } else if (fieldName.equals("email")) { e = fileItem.getString(); } else if (fieldName.equals("address1")) { ad1 = fileItem.getString(); } else if (fieldName.equals("address2")) { ad2 = fileItem.getString(); } else if (fieldName.equals("number")) { num = fileItem.getString(); } else if (fieldName.equals("pwd")) { p = fileItem.getString(); } else if (fieldName.equals("descrip")) { des = fileItem.getString(); } else if (fieldName.equals("compname")) { cmp = fileItem.getString(); } else if (fieldName.equals("workx")) { work = fileItem.getString(); } } else { agentphoto = new File(fileItem.getName()).getName(); System.out.println(agentphoto); try { // FOR UBUNTU add GETRESOURCE and GETPATH String fp = "/home/rushin/NetBeansProjects/The_Asset_Consultancy/web/images/profilepic/"; // String filePath= this.getServletContext().getResource("/images/profilepic").getPath()+"//"; System.out.println("====" + fp); fileItem.write(new File(fp + agentphoto)); } catch (Exception ex) { out.println(ex.toString()); } } } SessionFactory sf = NewHibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); // // String state=""; // Criteria cr = ss.createCriteria(StateMaster.class); // cr.add(Restrictions.eq("sId", Integer.parseInt(stateid))); // ArrayList<StateMaster> ar = (ArrayList<StateMaster>)cr.list(); // System.out.println("----------"+ar.size()); // if(ar.isEmpty()){ // // }else{ // state = ar.get(0).getSName(); // System.out.println("-------"+ar.get(0)); // } // // String city=""; // Criteria cr2 = ss.createCriteria(CityMaster.class); // cr2.add(Restrictions.eq("cityId", Integer.parseInt(cityid))); // ArrayList<CityMaster> ar2 = (ArrayList<CityMaster>)cr2.list(); // System.out.println("----------"+ar2.size()); // if(ar2.isEmpty()){ // // }else{ // city = ar2.get(0).getCityName(); // System.out.println("-------"+city); // } // // String area=""; // Criteria cr3 = ss.createCriteria(AreaMaster.class); // cr3.add(Restrictions.eq("areaId", Integer.parseInt(areaid))); // ArrayList<AreaMaster> ar3 = (ArrayList<AreaMaster>)cr3.list(); // System.out.println("----------"+ar3.size()); // if(ar3.isEmpty()){ // // }else{ // area = ar3.get(0).getAreaName(); // System.out.println("-------"+area); // } // // Criteria crr=ss.createCriteria(AgentDetail.class); // crr.add(Restrictions.eq("uId", ln.getUId())); // ArrayList<AgentDetail> arr=(ArrayList<AgentDetail>)crr.list(); // if(arr.isEmpty()) // { // out.print("array empty"); // } // else // { // AgentDetail agd=arr.get(0); AgentDetail agd2 = (AgentDetail) ss.get(AgentDetail.class, id); AgentDetail agd = new AgentDetail(); agd.setUId(agd2.getUId()); agd.setAId(agd2.getAId()); agd.setACompanyname(cmp); agd.setADescription(des); agd.setAEmail(e); agd.setAFname(fn); agd.setAImg(agentphoto); agd.setALname(lastn); agd.setANo(num); agd.setAWorkx(work); agd.setACity(city); agd.setAArea(area); agd.setAState(state); agd.setAAddress1(ad1); agd.setAAddress2(ad2); agd.setAStatus(null); agd.setARating(null); agd.setAStatus("Accepted"); // agd.getUId().setPwd(p); // agd.getUId().setUName(un); ss.evict(agd2); ss.update(agd); tr.commit(); // } RequestDispatcher rd = request.getRequestDispatcher("agentprofile.jsp"); rd.forward(request, response); } } catch (HibernateException e) { out.println(e.getMessage()); } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.jena.JenaXMLFileUpload.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (!isAuthorizedToDisplayPage(request, response, SimplePermission.USE_ADVANCED_DATA_TOOLS_PAGES.ACTION)) { return;//from w w w .j av a 2 s. c o m } VitroRequest vreq = new VitroRequest(request); //make a form for uploading a file request.setAttribute("title", "Upload file and convert to RDF"); request.setAttribute("bodyJsp", "/jenaIngest/xmlFileUpload.jsp"); request.setAttribute("modelNames", getModelMaker(vreq).listModels().toList()); request.setAttribute("models", null); RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + vreq.getAppBean().getThemeDir() + "css/edit.css\"/>"); try { rd.forward(request, response); } catch (Exception e) { System.out.println(this.getClass().getName() + " could not forward to view."); System.out.println(e.getMessage()); System.out.println(e.getStackTrace()); } }