0

I have one UserProfile class with FirstName,LastName,Email etc Properties. I want to pass that object from jsp to javascript displayPopup function.

Below is my code

<tr bgcolor="#fafafa" height="30px" style="cursor:pointer;" title="Click to view User Details." onclick="javascript:displayPopup('${userProfile}');">

But when i click on that row it is showing the error on browser console.

RBP
  • 481
  • 1
  • 9
  • 29
  • 2
    You cannot pass a server-side object to a JavaScript function like that; the concept makes no sense due to the nature of the two execution environments. – Pointy Oct 10 '13 at 14:28
  • 1
    Would it be useful to pass a JSON 'object' to an AJAX call and then you could retrieve the data you want from the JSON object. http://stackoverflow.com/questions/16697364/return-json-from-one-jsp-to-another/16751925#16751925 – Alex Theedom Oct 10 '13 at 14:33
  • 1
    Or create a `String summary` field in `UserProfile`, make sure the getter formats the message the way you want to see it on the client side, then use `displayPopup('${userProfile.summary}')`. – Tap Oct 10 '13 at 16:53

0 Answers0