Accessing bean value in jsp page

Accessing bean value in jsp page

I am trying to get the value from a bean and pass it across to a javascript. I am getting the error, the variable ptName is undefined. Can someone help me on this. Here is my code snippet.

<bean:define id="ptName" name="point" property="name"/>
<c:set var="searc" value="'" />
<c:set var="repl" value="`" />
<c:set var="ptName" value="${fn:replace(ptName, searc, repl)}"/>
<a href="javascript: parent.editPoint(parent.PointEditForm, '<bean:write name='point' property='id'/>', '<bean:write name='point' property='sortOrder'/>', ptName, '<bean:write name="point" property="info"/>', '<bean:write name='point' property='type.id'/>', '<bean:write name='point' property='sendMail'/>', '<bean:write name="point" property="mail"/>', '<bean:write name='point' property='CustList'/>', '<bean:write name='point' property='myId'/>', '<bean:write name='point' property='origin'/>' );">

What is <bean:define>? It is not a standard JSP action. If you are using a framework or set of custom tags, you need to let us know which one.

You confused javascript variable with java variable.

ptName you defined is a page scope java variable.

You can use it like this in javascript:

'${ptName}'

To be accurate, that doesn't really "use it" in JavaScript, it writes out the value into the response, which then becomes the markup of the page.

Copyright © 2007-2012 www.chuibin.com Chuibin Copyright