The URL class provides many constructors for creating URL objects. These constructors can all throw a MalformedURLException so it must be caught.
public URL(String spec)
public URL(String protocol, String host, int port, String file);
public URL(URL context, String spec)URL Parts that appear in spec replace the corresponding parts in context.
String param = getParameter("imagesource"); imageSource = new URL(getDocumentBase(), param + "/");This replaces the file name of the document by the parameter (with a trailing '/' added).