• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Context Root of WebApplication in javascript

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am in the process of changing all the paths in js files to prepend the context root to the paths.
I can get context path in the js by way of reading application.xml but that puts a restriction of not being able to read the application.xml from a relative path. Because application.xml is placed in META-INF which is not accessible to the outside world.

2nd way is i can include a header jsp in all the jsps and then have a common code like
<script type="text/javascript">
var CONTEXT_ROOT = '<%= request.getContextPath() %>';
</script>

now we could refer to context_root in all the js files.

is there any other alternative too?


thanks
sandeepraj
 
Sheriff
Posts: 67762
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Except for the fact that you are using scriptlets (in 2012? Scriptlets?) that's pretty much what I do.

To get the context path with the EL: ${pageContext.request.contextPath}
 
sandeeprajsingh tandon
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks..
yes its a 2001 code still not upgraded so yes..in 2012 i am using scrip lets.

thanks for your reply

thanks
sandeepraj
 
reply
    Bookmark Topic Watch Topic
  • New Topic