• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 759
  • Last Modified:

accessing a java object in javascript

I need to access java object in javascript. In one of the scenario in my current webpage a button is enabled only in certain circumstances, when i click that button a method on java object is to be called where calling that method is very costly. So i need to call only when i click that button. Right now i am getting that object using scriplet in my jsp and trying to pass the java object to javascript onclick() method as parameter which does not work. How can i acheive this?
1 Solution
Gibu GeorgeChief Technology OfficerCommented:
You cannot pass the java object to javascript as javascript works on the client side, where as  java works on the server side. What you can do is on the click of the button you can do an ajax call to the server and load the required object and yuo can send the resonse as an xml or text with the required values(not the object). A simple AJAX with jsp example is here
Murali MurugesanFull stack Java developerCommented:
can u post the gist of code that you have.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now