user1365067
user1365067

Reputation:

JSP tag alert in javascript

How can I alert JSP tag inside javascript?? Is it possible? I want to alert

 <%=%>

I tried:

 alert("<%=%>")

but it is not working.

Upvotes: 1

Views: 454

Answers (4)

Zaheer Ahmed
Zaheer Ahmed

Reputation: 28538

No need escape the character:

It is working here

alert("<%=%>")

Check console for errors, which blocking it to alert.

Upvotes: 1

Tiny Jiang
Tiny Jiang

Reputation: 48

<%
String a = "123";
%>


var v = '<%=a%>';
alert(v);

try it like this;

Upvotes: 0

TheEwook
TheEwook

Reputation: 11117

You can try that:

<script language="javascript">  
function one()  
{  
    alert("var: "+<%= var %> );  
}
</script>  

Upvotes: 0

SteveP
SteveP

Reputation: 19093

Try this:

alert("\<\%=\%\>");

The '\' characters escape the following character to stop them being interpreted as jsp delimiters.

Upvotes: 0

Related Questions