(Updated below)
Fundamentally, what you send from the client to the server via ajax is always a string. It can only be turned into something else by a server-side process interpreting it.
The question doesn't seem to make any sense. Unless you're using a Java applet on the client and LiveConnect, you don't have a Java class instance on the client at all.
If you did have a Java class instance on the client (e.g., from the applet), the only way to send it to the server would be:
Serialize it to a byte stream.
Encode that byte stream into a string (Base64 or similar).
Send that encoded string to the server via ajax.
Decode the string back into a byte stream on the server.
Deserialize it on the server.
...and there would almost certainly be a much better way of getting that information from the client to the server.
You've edited your question to say:
By the way, I am getting the java class instance like this :
<script type='text/javascript'>
var class_instance = "<%= my_class_instance %>";
</script>
That won't give you a "Java class instance" on the browser. At best, you'll have a string with some information in it. More likely, depending on what's inside your my_class_instance
server-side variable, you'll have a JavaScript syntax error. (E.g., if you have a '
or a line break or an invalid JavaScript escape sequence, etc., inside it.)
If you believe that's a Java class instance, you need to step back and study the fundamentals of web applications before trying to write this code.