List of usage examples for javax.servlet.http HttpServletResponse encodeRedirectUrl
@Deprecated
public String encodeRedirectUrl(String url);
From source file:MyServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { //redirect the user depending on the value of the 'go' param String destination = getInitParameter("go"); String contextPath = request.getContextPath(); if (destination == null || destination.equals("")) throw new ServletException("Missing or invalid 'go' parameter in " + getClass().getName()); if (destination.equals("weather")) //ensure URL rewriting response.sendRedirect(response.encodeRedirectURL(contextPath + "/weather")); if (destination.equals("maps")) //ensure URL rewriting response.sendRedirect(response.encodeRedirectURL(contextPath + "/maps")); }
From source file:com.netspective.sparx.value.BasicDbHttpServletValueContext.java
public void sendRedirect(String url) throws IOException { HttpServletResponse resp = (HttpServletResponse) response; resp.sendRedirect(resp.encodeRedirectURL(url)); redirected = true;/*from w w w . j av a2 s. com*/ }
From source file:org.muse.mneme.tool.SelectQuestionType.java
/** * {@inheritDoc}//ww w . j a va2 s . c o m */ public void get(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { if (params.length != 6) throw new IllegalArgumentException(); // security if (!this.poolService.allowManagePools(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } StringBuilder prevDestinationParamPath = new StringBuilder(); prevDestinationParamPath.append(params[2]); for (int i = 3; i < 6; i++) { prevDestinationParamPath.append("/"); prevDestinationParamPath.append(params[i]); } context.put("prevDestinationParamPath", prevDestinationParamPath.toString()); // the question types List<QuestionPlugin> questionTypes = this.mnemeService.getQuestionPlugins(); context.put("questionTypes", questionTypes); // for the selected question type - pre-select the top of the list Value value = this.uiService.newValue(); value.setValue(questionTypes.get(0).getType()); context.put("selectedQuestionType", value); // render uiService.render(ui, context); }
From source file:org.opennms.web.asset.ImportAssetsServlet.java
private void redirectWithErrorMessage(HttpServletRequest request, HttpServletResponse response, Exception e, String message) throws IOException, UnsupportedEncodingException { this.log(message, e); request.getSession().setAttribute("message", message); response.sendRedirect(response.encodeRedirectURL("import.jsp?showMessage=true")); }
From source file:org.dspace.authenticate.LDAPAuthentication.java
public String loginPageURL(Context context, HttpServletRequest request, HttpServletResponse response) { return response.encodeRedirectURL(request.getContextPath() + "/ldap-login"); }
From source file:org.muse.mneme.tool.ImportAsnSiteView.java
/** * {@inheritDoc}//from ww w . j av a 2 s. co m */ public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // [2] pools sort if (params.length != 3) { throw new IllegalArgumentException(); } String poolsSort = params[2]; if (!this.poolService.allowManagePools(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } Value selectedSite = this.uiService.newValue(); context.put("selectedSite", selectedSite); // read the form String destination = uiService.decode(req, context); // import the pools if ("IMPORT".equals(destination)) { String siteId = selectedSite.getValue(); destination = "/import_assignment/" + poolsSort + "/" + siteId; } res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); }
From source file:org.etudes.mneme.tool.ImportTqSiteView.java
/** * {@inheritDoc}// w ww . j av a2 s. com */ public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // [2] pools sort if (params.length != 3) { throw new IllegalArgumentException(); } String poolsSort = params[2]; if (!this.poolService.allowManagePools(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } Value selectedSite = this.uiService.newValue(); context.put("selectedSite", selectedSite); // read the form String destination = uiService.decode(req, context); // import the pools if ("IMPORT".equals(destination)) { String siteId = selectedSite.getValue(); destination = "/import_tq_assessment/" + poolsSort + "/" + siteId; } res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); }
From source file:org.muse.mneme.tool.GradeQuestionsListView.java
/** * {@inheritDoc}//from www. ja v a 2 s. c o m */ public void get(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // [2] grades view sort, [3] aid if (params.length != 4) throw new IllegalArgumentException(); // check for user permission to access the assessments for grading if (!this.submissionService.allowEvaluate(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } // grades view sort context.put("sort_grades", params[2]); // get assessment Assessment assessment = this.assessmentService.getAssessment(params[3]); if (assessment == null) { res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.invalid))); return; } context.put("assessment", assessment); uiService.render(ui, context); }
From source file:org.etudes.mneme.tool.ImportTqPoolView.java
/** * {@inheritDoc}//from ww w.jav a2s .co m */ public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { // [2] pools sort if (params.length != 3) { throw new IllegalArgumentException(); } String poolsSort = params[2]; if (!this.poolService.allowManagePools(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } Values selectedPools = this.uiService.newValues(); context.put("selectedPools", selectedPools); // read the form String destination = uiService.decode(req, context); // import the pools if ("IMPORT".equals(destination)) { for (String id : selectedPools.getValues()) { try { this.importService.importPool(id, toolManager.getCurrentPlacement().getContext()); } catch (AssessmentPermissionException e) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } } destination = "/pools/" + poolsSort; } res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); }
From source file:org.muse.mneme.tool.SelectQuestionType.java
/** * {@inheritDoc}//from w ww .ja va2s . c o m */ public void post(HttpServletRequest req, HttpServletResponse res, Context context, String[] params) throws IOException { if (params.length != 6) throw new IllegalArgumentException(); // security if (!this.poolService.allowManagePools(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } // for the selected question type Value value = this.uiService.newValue(); context.put("selectedQuestionType", value); // read the form String destination = uiService.decode(req, context); String selectedQuestionType = value.getValue(); if ((selectedQuestionType != null) && (destination.startsWith("CREATE"))) { Pool pool = this.poolService.getPool(params[3]); if (pool == null) { // TODO: do this better! res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.invalid))); return; } if (!this.poolService.allowManagePools(toolManager.getCurrentPlacement().getContext())) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } // create the question of the appropriate type (all the way to save) Question newQuestion = null; try { newQuestion = this.questionService.newQuestion(pool, selectedQuestionType); } catch (AssessmentPermissionException e) { // redirect to error res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, "/error/" + Errors.unauthorized))); return; } // form the destionation destination = destination.replaceFirst("CREATE", "/question_edit"); destination += "/" + newQuestion.getId(); // redirect res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); return; } res.sendRedirect(res.encodeRedirectURL(Web.returnUrl(req, destination))); }