tags:

views:

167

answers:

2

Hi!

I am running an application using jsp (gsp actually) under Tomcat. All URLs are absolute. That is, every href begins with a "/". For example:

<a href="/mytool/role/index" class="menulink">Role</a>

Every request will receive a parameter called SYS.WEBSYSTEM_PREFIX which must be prepended to every URL.

That is, if the request is

http://myDomain/mytool/xxx?SYS.WEBSYSTEM_PREFIX=some_path

then the URL from above has to be rewritten as:

    some_path/mytool/index

I think that this can be globally done using the HTML tag.

I've intended the following:

<base href=<% request.getParameter("SYS.WEBSYSTEM_PREFIX"); %> />

but it didn't work.

Therefore the questions are:

  • Is possible to cope this problem in this way?
  • If yes. How to do this?

Thanks in advance.

Luis

+1  A: 

The HTML <base href=""/> doesn't work when your <a href=""> start with a /.

Lance Rushing
A: 

it would be a better idea to write a jsp custom tag that you will use instead of the a tag, which will append that path to the begining of your paths.

some think like this:

<custom:a href="/some/path" text="blah"/>

you may need to add some other attributes like onclick etc as well.

mkoryak