Passing values into javascript

I can’t find the answer on various programmer fora.

I have a password dialog which is a .jsp. There some java webapp code associated that checks the password and does a request.setAttribute(“reportURL”,<some string); if the passoword is correct

In the .jsp I have


<logic:notEmpty name="reportURL">
<script language="Javascript">
{
	alert('reportURL set');
	try
	{
		alert(reportURL);
	}
	catch (err)
	{
		alert (err.description);
	}
}
</script>
</logic:notEmpty>

Which basically tells me that reportURL is undefined (the first alert does display)
How do I get the value of reportURL in this block?

Thanks,
Brian

Well, for one thing, I use JSTL tags as opposed to those Struts (or are they just Jakarta) tags, but that’s neither here nor there. Parameters and scoped variables are available to Tomcat to render the page, but they are not available in the rendered code, so if you want javascript to use the values, you have to render them in the page. Since the javascript is inline in a jsp, you could use EL to reference them in js, but otherwise, they will be undefined. If the value were embedded in the DOM, for example as the value of an input tag, you could reference it in the javascript using things like getElementById.

E.g.,

var reportUrl = ‘${reportUrl}’; // the rest of the js code would follow

FWIW,
Rob