This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Context Root of WebApplication in javascript

 
sandeeprajsingh tandon
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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: 79
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic