Probably not the solution you were looking for, but this is what I did to get around not being able to figure out the path to my script:
Above my script has been loaded off the file system by my portlet and I inject the script into the head "manually". Probably not an issue for a short script, but I would imagine that finding the correct path and setting that in your JSP is better in the long run when your server is under heavy use.
Thank you nollie,
Replace the location /js/mylib.js with <%= renderRequest.getContextPath() %>/js/mylib.js i.e.