/** * Sets the value of a specific cookie.<p> * If no cookie exists with the value, a new cookie will be created. * * @param jsp the CmsJspActionElement to use * @param name the name of the cookie * @param value the value of the cookie */ public static void setCookieValue(CmsJspActionElement jsp, String name, String value) { Cookie[] cookies = jsp.getRequest().getCookies(); for (int i = 0; (cookies != null) && (i < cookies.length); i++) { if (name.equalsIgnoreCase(cookies[i].getName())) { cookies[i].setValue(value); return; } } Cookie cookie = new Cookie(name, value); jsp.getResponse().addCookie(cookie); }
/** * Sets the value of a specific cookie.<p> * If no cookie exists with the value, a new cookie will be created. * * @param jsp the CmsJspActionElement to use * @param name the name of the cookie * @param value the value of the cookie */ public static void setCookieValue(CmsJspActionElement jsp, String name, String value) { Cookie[] cookies = jsp.getRequest().getCookies(); for (int i = 0; (cookies != null) && (i < cookies.length); i++) { if (name.equalsIgnoreCase(cookies[i].getName())) { cookies[i].setValue(value); return; } } Cookie cookie = new Cookie(name, value); jsp.getResponse().addCookie(cookie); }
/** * Redirects the response to the target link using a "301 - Moved Permanently" header.<p> * * This implementation will work only on JSP pages in OpenCms that use the default JSP loader implementation.<p> * * @param jsp the OpenCms JSP context * @param target the target link */ public static void redirectPermanently(CmsJspActionElement jsp, String target) { String newTarget = OpenCms.getLinkManager().substituteLink(jsp.getCmsObject(), target, null, true); jsp.getRequest().setAttribute( CmsRequestUtil.ATTRIBUTE_ERRORCODE, new Integer(HttpServletResponse.SC_MOVED_PERMANENTLY)); jsp.getResponse().setHeader(HEADER_LOCATION, newTarget); jsp.getResponse().setHeader(HEADER_CONNECTION, "close"); }
/** * Sends a http redirect to the specified URI in the OpenCms VFS.<p> * * @param location the location the response is redirected to * @throws IOException in case redirection fails */ public void sendCmsRedirect(String location) throws IOException { // TOOD: IBM Websphere v5 has problems here, use forward instead (which has other problems) getJsp().getResponse().sendRedirect(OpenCms.getSystemInfo().getOpenCmsContext() + location); }
/** * Sends a http redirect to the specified URI in the OpenCms VFS.<p> * * @param location the location the response is redirected to * @throws IOException in case redirection fails */ public void sendCmsRedirect(String location) throws IOException { // TOOD: IBM Websphere v5 has problems here, use forward instead (which has other problems) getJsp().getResponse().sendRedirect(OpenCms.getSystemInfo().getOpenCmsContext() + location); }
/** * Redirects the response to the target link.<p> * * Use this method instead of {@link javax.servlet.http.HttpServletResponse#sendRedirect(java.lang.String)} * to avoid relative links with secure sites (and issues with apache).<p> * * @param jsp the OpenCms JSP context * @param target the target link * * @throws IOException if something goes wrong during redirection */ public static void redirectRequestSecure(CmsJspActionElement jsp, String target) throws IOException { jsp.getResponse().sendRedirect(OpenCms.getLinkManager().substituteLink(jsp.getCmsObject(), target, null, true)); }
/** * Redirects the response to the target link.<p> * * Use this method instead of {@link javax.servlet.http.HttpServletResponse#sendRedirect(java.lang.String)} * to avoid relative links with secure sites (and issues with apache).<p> * * @param jsp the OpenCms JSP context * @param target the target link * * @throws IOException if something goes wrong during redirection */ public static void redirectRequestSecure(CmsJspActionElement jsp, String target) throws IOException { jsp.getResponse().sendRedirect(OpenCms.getLinkManager().substituteLink(jsp.getCmsObject(), target, null, true)); }
/** * Redirects the response to the target link using a "301 - Moved Permanently" header.<p> * * This implementation will work only on JSP pages in OpenCms that use the default JSP loader implementation.<p> * * @param jsp the OpenCms JSP context * @param target the target link */ public static void redirectPermanently(CmsJspActionElement jsp, String target) { target = OpenCms.getLinkManager().substituteLink(jsp.getCmsObject(), target); jsp.getResponse().setHeader(HEADER_CONNECTION, "close"); try { HttpServletResponse response = jsp.getResponse(); if (response instanceof CmsFlexResponse) { ((CmsFlexResponse)jsp.getResponse()).sendRedirect(target, true); } else { response.setHeader("Location", target); response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); } } catch (IOException e) { LOG.error(Messages.get().getBundle().key(Messages.ERR_IOERROR_0), e); } }
/** * Performs the user agreement declined action, will be called by the JSP page.<p> * * @throws IOException if problems while redirecting occur */ public void actionDecline() throws IOException { getJsp().getRequest().getSession().invalidate(); getJsp().getResponse().sendRedirect(getJsp().link(getParamWpres())); }
/** * Performs the the user agreement accept action, will be called by the JSP page.<p> * * @throws IOException if problems while redirecting occur */ public void actionAccept() throws IOException { acceptAgreement(); // redirect to the originally requested resource getJsp().getResponse().sendRedirect(getJsp().link(getParamWpres())); }
getCms().getRequestContext().getEncoding()); HttpServletResponse res = getJsp().getResponse(); HttpServletRequest req = getJsp().getRequest();
String redirectLink = getJsp().link(bodyLinkWithParams); getJsp().getResponse().sendRedirect(redirectLink);
String redirectLink = getJsp().link(bodyLinkWithParams); getJsp().getResponse().sendRedirect(redirectLink);
/** * Redirects to the given page with the given parameters.<p> * * @param wp the workplace object * @param pagePath the path to the page to redirect to * @param params the parameters to send * * @throws IOException in case of errors during forwarding * @throws ServletException in case of errors during forwarding */ public void jspForwardPage(CmsWorkplace wp, String pagePath, Map<String, String[]> params) throws IOException, ServletException { Map<String, String[]> newParams = createToolParams(wp, pagePath, params); if (pagePath.indexOf("?") > 0) { pagePath = pagePath.substring(0, pagePath.indexOf("?")); } wp.setForwarded(true); // forward to the requested page uri CmsRequestUtil.forwardRequest( wp.getJsp().link(pagePath), CmsRequestUtil.createParameterMap(newParams), wp.getJsp().getRequest(), wp.getJsp().getResponse()); }
/** * Redirects to the given page with the given parameters.<p> * * @param wp the workplace object * @param pagePath the path to the page to redirect to * @param params the parameters to send * * @throws IOException in case of errors during forwarding * @throws ServletException in case of errors during forwarding */ public void jspForwardPage(CmsWorkplace wp, String pagePath, Map params) throws IOException, ServletException { Map newParams = createToolParams(wp, pagePath, params); if (pagePath.indexOf("?") > 0) { pagePath = pagePath.substring(0, pagePath.indexOf("?")); } wp.setForwarded(true); // forward to the requested page uri CmsRequestUtil.forwardRequest( wp.getJsp().link(pagePath), CmsRequestUtil.createParameterMap(newParams), wp.getJsp().getRequest(), wp.getJsp().getResponse()); }
/** * Forwards to the specified location in the OpenCms VFS.<p> * * @param location the location the response is redirected to * @param params the map of parameters to use for the forwarded request * * @throws IOException in case the forward fails * @throws ServletException in case the forward fails */ public void sendForward(String location, Map params) throws IOException, ServletException { setForwarded(true); // params must be arrays of String, ensure this is the case params = CmsRequestUtil.createParameterMap(params); CmsRequestUtil.forwardRequest(getJsp().link(location), params, getJsp().getRequest(), getJsp().getResponse()); }
/** * Forwards to the specified location in the OpenCms VFS.<p> * * @param location the location the response is redirected to * @param params the map of parameters to use for the forwarded request * * @throws IOException in case the forward fails * @throws ServletException in case the forward fails */ public void sendForward(String location, Map<String, String[]> params) throws IOException, ServletException { setForwarded(true); // params must be arrays of String, ensure this is the case Map<String, String[]> parameters = CmsRequestUtil.createParameterMap(params); CmsRequestUtil.forwardRequest( getJsp().link(location), parameters, getJsp().getRequest(), getJsp().getResponse()); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions() */ @Override public void executeListSingleActions() throws IOException, ServletException { if (getParamListAction().equals(LIST_ACTION_TRANSFER) || getParamListAction().equals(LIST_DEFACTION_TRANSFER)) { // execute the delete action try { Iterator it = CmsStringUtil.splitAsList(getParamUserid(), CmsHtmlList.ITEM_SEPARATOR, true).iterator(); while (it.hasNext()) { CmsUUID id = new CmsUUID((String)it.next()); getCms().deleteUser(id, new CmsUUID(getSelectedItem().getId())); } CmsRequestUtil.forwardRequest(getParamCloseLink(), getJsp().getRequest(), getJsp().getResponse()); setForwarded(true); } catch (CmsException e) { throw new CmsRuntimeException( Messages.get().container(Messages.ERR_TRANSFER_USER_1, getSelectedItem().get(LIST_COLUMN_NAME)), e); } } else { throwListUnsupportedActionException(); } listSave(); }
byte[] result = loader.dump(getCmsObject(), file, element, locale, getRequest(), getResponse()); return new String(result, getRequestContext().getEncoding()); } catch (UnsupportedEncodingException uee) {
/** * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions() */ @Override public void executeListSingleActions() throws IOException, ServletException, CmsRuntimeException { if (getParamListAction().equals(LIST_DEFACTION_TRANSFER) || getParamListAction().equals(LIST_ACTION_TRANSFER)) { try { getCms().deleteGroup(new CmsUUID(getParamGroupid()), new CmsUUID(getSelectedItem().getId())); CmsRequestUtil.forwardRequest(getParamCloseLink(), getJsp().getRequest(), getJsp().getResponse()); setForwarded(true); } catch (CmsException e) { throw new CmsRuntimeException( Messages.get().container(Messages.ERR_TRANSFER_GROUP_1, getSelectedItem().get(LIST_COLUMN_NAME)), e); } } else { throwListUnsupportedActionException(); } listSave(); }