@Nonnull @ReturnsMutableCopy public PhotonRequestParameters getParametersFromURL (@Nonnull final ISimpleURL aURL, @Nonnull final IMenuTree aMenuTree) { final PhotonRequestParameters ret = new PhotonRequestParameters (); ret.setLocaleFromString (GlobalLocaleManager.getInstance (), aURL.params ().getFirstParamValue (getRequestParamNameLocale ())); ret.setMenuItemFromString (aMenuTree, aURL.params ().getFirstParamValue (getRequestParamNameMenuItem ())); return ret; }
/** * Encodes the specified URL by including the session ID in it, or, if * encoding is not needed, returns the URL unchanged. The implementation of * this method includes the logic to determine whether the session ID needs to * be encoded in the URL. For example, if the browser supports cookies, or * session tracking is turned off, URL encoding is unnecessary. * <p> * For robust session tracking, all URLs emitted by a servlet should be run * through this method. Otherwise, URL rewriting cannot be used with browsers * which do not support cookies. * * @param aURL * the url to be encoded. May not be <code>null</code>. * @return the encoded URL if encoding is needed. Never <code>null</code>. */ @Nonnull default ISimpleURL encodeURL (@Nonnull final ISimpleURL aURL) { ValueEnforcer.notNull (aURL, "URL"); // Encode only the path and copy params and anchor return new SimpleURL (encodeURL (aURL.getPath ()), aURL.params (), aURL.getAnchor ()); }
/** * Encodes the specified URL for use in the <code>sendRedirect</code> method * or, if encoding is not needed, returns the URL unchanged. The * implementation of this method includes the logic to determine whether the * session ID needs to be encoded in the URL. Because the rules for making * this determination can differ from those used to decide whether to encode a * normal link, this method is separated from the <code>encodeURL</code> * method. * <p> * All URLs sent to the <code>HttpServletResponse.sendRedirect</code> method * should be run through this method. Otherwise, URL rewriting cannot be used * with browsers which do not support cookies. * * @param aURL * the url to be encoded. May not be <code>null</code>. * @return the encoded URL if encoding is needed. Never <code>null</code>. * @see #encodeURL(String) */ @Nonnull default ISimpleURL encodeRedirectURL (@Nonnull final ISimpleURL aURL) { ValueEnforcer.notNull (aURL, "URL"); // Encode only the path and copy params and anchor return new SimpleURL (encodeRedirectURL (aURL.getPath ()), aURL.params (), aURL.getAnchor ()); }
/** * Get the passed string without an eventually contained session ID like in * "test.html;JSESSIONID=1234?param=value". * * @param aURL * The value to strip the session ID from the path * @return The value without a session ID or the original string. */ @Nonnull public static SimpleURL getWithoutSessionID (@Nonnull final ISimpleURL aURL) { ValueEnforcer.notNull (aURL, "URL"); // Strip the parameter from the path, but keep parameters and anchor intact! // Note: using URLData avoid parsing, since the data was already parsed! return new SimpleURL (new URLData (getWithoutSessionID (aURL.getPath ()), aURL.params (), aURL.getAnchor ())); }