Added getServletURL().
git-svn-id: https://samskivert.googlecode.com/svn/trunk@1045 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: RequestUtils.java,v 1.5 2002/08/20 18:57:31 mdb Exp $
|
// $Id: RequestUtils.java,v 1.6 2003/02/03 03:46:32 mdb Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -88,4 +88,20 @@ public class RequestUtils
|
|||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepends the server, port and servlet context path to the supplied
|
||||||
|
* path, resulting in a fully-formed URL for requesting a servlet.
|
||||||
|
*/
|
||||||
|
public static String getServletURL (HttpServletRequest req, String path)
|
||||||
|
{
|
||||||
|
StringBuffer buf = HttpUtils.getRequestURL(req);
|
||||||
|
String sname = req.getServletPath();
|
||||||
|
buf.delete(buf.length() - sname.length(), buf.length());
|
||||||
|
if (!path.startsWith("/")) {
|
||||||
|
buf.append("/");
|
||||||
|
}
|
||||||
|
buf.append(path);
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user