problem creating url

I have the following code and for some reason, it can not construct the URL.. When I reference <%=Parameter.PROCEDURE_INDEX_PARAM%> it does not seem to understand it. When I hard-code the value ("procedureindex") it works.

If I reference Parameter.PROCEDURE_INDEX_PARAM in my scriptlet code, it works just fine.

What am I doing wrong?

<%@ page info="Procedure Results" import="adac.web.util.Parameter" %>

<script language=javascript>

function blankRightWindow(webServerIP, uid, contextPath, strCnt, showImages, viewerType){

if (showImages){

if(viewerType ==null || viewerType.toUpperCase() =="AMICAS"){

url ="http://" + webServerIP +"/servlet/com.amicas.servlet.integration.CernerEmbeddedWebViewer?";

url = url + uid;

}else{

alert ("cnt " + strCnt);

//url = contextPath + "image.jsp?" + "procedureindex" + "=" + strCnt

url = contextPath +"image.jsp?" + <%=Parameter.PROCEDURE_INDEX_PARAM%> +"=" + strCnt

alert ("URL: " + url);

}

}

</script>

[1666 byte] By [E.Sokola] at [2007-10-2 4:38:49]
# 1

Take a look at the generated html/javascript from this page:

Assuming the constant is declared aspublic class Parameter{

public static final String PROCEDURE_INDEX_PARAM = "procedureindex";

}

It will be something like this in the html page.

url = contextPath + "image.jsp?" + procedureindex + "=" +

as most likely there is no javascript variable called procedure index, its value will undefined.

The following should do it

// putting quotes around the scriptlet expression, so it is interpreted as string

url = contextPath + "image.jsp?" + "<%=Parameter.PROCEDURE_INDEX_PARAM%>" + "=" + strCnt

// just inserting it into the javascript string

url = contextPath + "image.jsp?<%=Parameter.PROCEDURE_INDEX_PARAM%>=" + strCnt

Cheers,

evnafets

evnafetsa at 2007-7-16 0:11:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks. I was just about to post the fact I forgot the quotes around the substitution.so it should be:url = contextPath + "image.jsp?" + "<%=Parameter.PROCEDURE_INDEX_PARAM%>" + "=" + strCnt
esokola at 2007-7-16 0:11:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...