@ -260,7 +260,6 @@ public abstract class WebUtils {
@@ -260,7 +260,6 @@ public abstract class WebUtils {
return realPath ;
}
/ * *
* Determine the session id of the given request , if any .
* @param request current HTTP request
@ -470,20 +469,6 @@ public abstract class WebUtils {
@@ -470,20 +469,6 @@ public abstract class WebUtils {
request . removeAttribute ( ERROR_SERVLET_NAME_ATTRIBUTE ) ;
}
/ * *
* Expose the given Map as request attributes , using the keys as attribute names
* and the values as corresponding attribute values . Keys need to be Strings .
* @param request current HTTP request
* @param attributes the attributes Map
* /
public static void exposeRequestAttributes ( ServletRequest request , Map < String , ? > attributes ) {
Assert . notNull ( request , "Request must not be null" ) ;
Assert . notNull ( attributes , "Attributes Map must not be null" ) ;
for ( Map . Entry < String , ? > entry : attributes . entrySet ( ) ) {
request . setAttribute ( entry . getKey ( ) , entry . getValue ( ) ) ;
}
}
/ * *
* Retrieve the first cookie with the given name . Note that multiple
* cookies can have the same name but different paths or domains .
@ -629,69 +614,6 @@ public abstract class WebUtils {
@@ -629,69 +614,6 @@ public abstract class WebUtils {
return params ;
}
/ * *
* Return the target page specified in the request .
* @param request current servlet request
* @param paramPrefix the parameter prefix to check for
* ( e . g . "_target" for parameters like "_target1" or "_target2" )
* @param currentPage the current page , to be returned as fallback
* if no target page specified
* @return the page specified in the request , or current page if not found
* /
public static int getTargetPage ( ServletRequest request , String paramPrefix , int currentPage ) {
Enumeration < String > paramNames = request . getParameterNames ( ) ;
while ( paramNames . hasMoreElements ( ) ) {
String paramName = paramNames . nextElement ( ) ;
if ( paramName . startsWith ( paramPrefix ) ) {
for ( int i = 0 ; i < WebUtils . SUBMIT_IMAGE_SUFFIXES . length ; i + + ) {
String suffix = WebUtils . SUBMIT_IMAGE_SUFFIXES [ i ] ;
if ( paramName . endsWith ( suffix ) ) {
paramName = paramName . substring ( 0 , paramName . length ( ) - suffix . length ( ) ) ;
}
}
return Integer . parseInt ( paramName . substring ( paramPrefix . length ( ) ) ) ;
}
}
return currentPage ;
}
/ * *
* Extract the URL filename from the given request URL path .
* Correctly resolves nested paths such as "/products/view.html" as well .
* @param urlPath the request URL path ( e . g . "/index.html" )
* @return the extracted URI filename ( e . g . "index" )
* /
public static String extractFilenameFromUrlPath ( String urlPath ) {
String filename = extractFullFilenameFromUrlPath ( urlPath ) ;
int dotIndex = filename . lastIndexOf ( '.' ) ;
if ( dotIndex ! = - 1 ) {
filename = filename . substring ( 0 , dotIndex ) ;
}
return filename ;
}
/ * *
* Extract the full URL filename ( including file extension ) from the given
* request URL path . Correctly resolve nested paths such as
* "/products/view.html" and remove any path and or query parameters .
* @param urlPath the request URL path ( e . g . "/products/index.html" )
* @return the extracted URI filename ( e . g . "index.html" )
* /
public static String extractFullFilenameFromUrlPath ( String urlPath ) {
int end = urlPath . indexOf ( '?' ) ;
if ( end = = - 1 ) {
end = urlPath . indexOf ( '#' ) ;
if ( end = = - 1 ) {
end = urlPath . length ( ) ;
}
}
int begin = urlPath . lastIndexOf ( '/' , end ) + 1 ;
int paramIndex = urlPath . indexOf ( ';' , begin ) ;
end = ( paramIndex ! = - 1 & & paramIndex < end ? paramIndex : end ) ;
return urlPath . substring ( begin , end ) ;
}
/ * *
* Parse the given string with matrix variables . An example string would look
* like this { @code "q1=a;q1=b;q2=a,b,c" } . The resulting map would contain