Navigate using custom tag

Hello folks,

I am trying to navigate to a servlet from a jsp using the navigate() javascript method. Within the method I am using a custom tag to supply the web context root. If I use request.getContextPath() everything is fine, but if I use the custom tag (which is what I want), I get an "Object Expected" error. Code snippet below. Any help would be appreciated.

<SCRIPT type="text/JavaScript">

function doSomething(){

navigate('<context:GetWebContextRoot/>/servlet/framework.components.LogonControllerServlet?command=logoff');

}

</SCRIPT>

[709 byte] By [stentata] at [2007-11-26 19:05:09]
# 1
Does <context:GetWebContextRoot/> return anything? Shoud the 'G' in 'get' be lowercase?
bckrispia at 2007-7-9 20:55:11 > top of Java-index,Java Essentials,Java Programming...
# 2

> Does <context:GetWebContextRoot/> return anything?

> Shoud the 'G' in 'get' be lowercase?

Thanks for the reply. Yes <context:GetWebContextRoot/> returns the context root path, and the case is correct. The tag does what it is supposed to do, but the jsp gives me an "Object Expected" error.

stentata at 2007-7-9 20:55:11 > top of Java-index,Java Essentials,Java Programming...
# 3
If <context:GetWebContextRoot/> is indeed a JSP tag , what is it doing inside a javascript string? Put it outside the single quotes (and add it to the js string), otherwise it won't be processed by the server.
karma-9a at 2007-7-9 20:55:11 > top of Java-index,Java Essentials,Java Programming...
# 4

> If <context:GetWebContextRoot/> is indeed a

> JSP tag , what is it doing inside a javascript

> string? Put it outside the single quotes (and add it

> to the js string), otherwise it won't be processed by

> the server.

Tried that already,

navigate(<context:GetWebContextRoot/> + '/servlet/framework.components.LogonControllerServlet?command=logoff');

here is the resulting source:

navigate(/MyApp '/servlet/framework.components.LogonControllerServlet?command=logoff');

Same error.

stentata at 2007-7-9 20:55:11 > top of Java-index,Java Essentials,Java Programming...
# 5

> If <context:GetWebContextRoot/> is indeed a

> JSP tag , what is it doing inside a javascript

> string? Put it outside the single quotes (and add it

> to the js string), otherwise it won't be processed by

> the server.

Wrong. The JSP Tag expansion isn't supressed by Javascript quotes.

It looks like you javascript is wrong. Try window.navigate('...

bckrispia at 2007-7-9 20:55:11 > top of Java-index,Java Essentials,Java Programming...
# 6

> Wrong. The JSP Tag expansion isn't supressed by

> Javascript quotes.

>

> It looks like you javascript is wrong. Try

> window.navigate('...

Thanks, but Same result.

The navigate code works like a charm and produces the same source when I use the following:window.navigate('<%=request.getContextPath()%>/servlet/framework.components.LogonControllerServlet?command=logoff');

but it's not what I need to do.

stentata at 2007-7-9 20:55:11 > top of Java-index,Java Essentials,Java Programming...
# 7
Thanks all for your help, the problem was with my custom tag, it was returning the context path with a carriage return.
stentata at 2007-7-9 20:55:11 > top of Java-index,Java Essentials,Java Programming...
# 8
Great! You can thank me with Dukes. :)
bckrispia at 2007-7-9 20:55:11 > top of Java-index,Java Essentials,Java Programming...