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]

> 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.
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.
> 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.
> 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('...
> 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.