2

I'm trying to make a homepage with a head and a tail jsp files in the root. Also I have the same _head and _tail jsp just for simple use at the future if I need it. In the head jsp, I added two js files, one css files in it.

I made another folder on the head jsp root named bbs. here, I made another file register jsp and this includes the head and the tail on the root. Structures are like these...

root
|---bbs
|  |-_head.jsp
|  |-_tail.jsp
|  |-register.jsp
|
|---css
|---js
|
|-head.jsp
|-tail.jsp
|-index.jsp

index.jsp is just a blank file with the character encoding and include file of head and tail. the file in bbs _head and _tail both are to include the root's head and tail. register.jsp is only for the body coding.

Now, the problem is that when I load the register.jsp, the css and the js all located in the root are now pointed in bbs. I want to try to make a relative path string variable in register.jsp so I could use the path variable in the head.jsp. any ideas?

gavenkoa
  • 45,285
  • 19
  • 251
  • 303
Steve Gom
  • 75
  • 3
  • 9

1 Answers1

3

You could move the register.jsp to root as it uses head.jsp and tail.jsp instead of _head and _tail versions.

Else,

You could get the context path using ${pageContext.request.contextPath}

If you want to set a base path for all relative links so that you don't need to repeat ${pageContext.request.contextPath} in every relative link, use the <base> tag.

There is a good explanation here

Community
  • 1
  • 1
John Eipe
  • 10,922
  • 24
  • 72
  • 114