Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Context root and links  RSS feed

 
Jonathan Cone
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys and gals,

I have a web application which I'm trying to refactor into a modestly involved directory structure (20+/- JSPs). I also have header and footer files (which contain links and images) present on all of these pages. What I am trying to figure out is how these links should be composed relative to the context root. I was under the impression that the following code would point to the file specified under 'tomcat/webapps/myApp'



e.g. '/webapps/myApp/style/styles.css'

Instead, this seems (to me) to be pointing at '/webapps/ROOT/style/styles.css'. Do I have to go through and prepend 'myApp' to each link in the application? I can't imagine this is the case because it would be a hassle if you ever wanted to change your application name. Is there an EL implicit object that I should be using for this?

Any tips would be appreciated, thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, all server-relative urls need the app context. You can either use the base tag to set the base and use relative addressing, or fix the links.

To avoid hard-coding the context path (good idea) use ${pageContext.request.contextPath}.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!