I want to display the value of variable named "id" in my code. The code is -
index.html(line 5)-
<div class="marginTable" data-pubid="<%=id%>" data-count="5">
But whenever i am executing it, it is throwing error An error occurred at line: 5 in the jsp file: /index.html id cannot be resolved to a variable. How to get out of this?
To display the server side variables in jsp , you can use implicit object out
.
some thing like this,
<div class="marginTable" data-count="5">
<%=id%>
</div>
But using scriptlets is considered as the bad practice . so you may use EL for more info see this How to avoid Java code in JSP files? as,
${id}