URLs in javascript

I have an ajax function that I'd like in a js file. I'd like it accessable to any page that has a need for it. If I access it from two different pages in two different directory structures, how would I word the url for the script that the function calls so that the script will be able to be accessed no matter where the function is called from (the jsp page).

[369 byte] By [vinays84a] at [2007-11-26 16:51:00]
# 1

Actually one resource can have two different URL's. URL for one java script (js) is same. You need to same same URL in any jsp.

Like

1.jsp

===================================================================

<script language="javascript" src="<%=request.getContextPath()%>/javascript/abc.js">

<%

//do something else

%>

===================================================================

2.jsp

===================================================================

<script language="javascript" src="<%=request.getContextPath()%>/javascript/abc.js">

//same url is used for that js

rinkua at 2007-7-8 23:18:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

I think I was a little unclear in my explanation. Sorry!

I wasn't referring to the url of the javascript file. I was referring to the url contained in a function in the javascript file. For example, suppose I wanted a simple javascript function which would redirect me to certain page:

redirect.js :

function redirectToPageA() {

var newHREF= "/directoryA/a.jsp"

location.href=newHREF

}

Now I'd like to include redirect.js and call the redirect function from two different jsp files with two different directory pathes. My problem is calling the function from 1.jsp will change the href to 1.jsp 's path+newHREF and calling it from 2.jsp will change the href to 2.jsp 's path+newHREF. I'd like to change newHREF to something so that whatever jsp its called from will yield the same results.

vinays84a at 2007-7-8 23:18:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...