Say I have a webapp (http://mydomain.com/test/
) with three files in a subdirectory (123):
Index.jsp reads data from data.jsp and test.jsp. It has the following code in it:
String dataUrl = "http://localhost:8080/test/123/data.jsp
String tUrl = "http://localhost:8080/test/123/test.jsp
URL dataAuth = new URL(dataUrl);
URL tAuth = new URL(tUrl);
What happens here is that it reads data from these files in the same folder. What I want is to be able to read data.jsp from a relative path (like: String dataUrl = "data.jsp";) or get the path name (test/123) from the request URL. Now I have to change the url for each folder where I use this code. I want this to be done dynamically. How can I do this?