Reputation: 57
Why does the alert box not work?
<script>
<% Player player = (Player) request.getAttribute("player"); %>
alert(<%=player.getTempId()%>);
</script>
Upvotes: 1
Views: 39
Reputation: 3488
I'm guessing the function returns a string. try this:
alert("<%=player.getTempId()%>");
Because if a string is returned without quotes you'll get the page to render this:
alert(aString) //and then you'll get an error that aString is not defined.
By adding "" the page will render like so:
alert("aString") //and will work
Upvotes: 1