http://stackoverflow.com/questions/6615641/how-do-you-get-the-contextpath-from-javascript-the-right-way

 

function getContextPath01() {
    var ctxPath = window.location.pathname.substring(0, window.location.pathname.indexOf("/",2));
    alert("<%= request.getContextPath()%>:"+ctxPath);
    return ctxPath;
}


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

http://megatechnics.tistory.com/entry/%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EC%97%90%EC%84%9C-ContextPath-%EA%B5%AC%ED%95%98%EA%B8%B0-javascript

 

 function getContextPath(){
      var offset=location.href.indexOf(location.host)+location.host.length;
      var ctxPath=location.href.substring(offset,location.href.indexOf('/',offset+1));
  
      alert("<%= request.getContextPath()%>"+ctxPath);
      return ctxPath;
 }











Posted by 張's blog
,