Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8790597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:41:58+00:00 2026-06-13T22:41:58+00:00

I am trying to send the JAVA CLASS INSTANCE from my javascript code to

  • 0

I am trying to send the JAVA CLASS INSTANCE from my javascript code to the JSP file via ajax . How can i send ? I tried sending the instance like this :

   data = {}
   data['my_instance'] = JAVA_CLASS_INSTANCE

and sending this data via ajax , problem is , in JSP, it is receiving it as a string rather than a class

By the way, I am getting the java class instance like this :

<script type='text/javascript'>
     var class_instance = "<%= my_class_instance %>"; //if this method is wrong, plz tell me correct method to get instance and send via ajax. Already I have a form, along with the form data, i am trying to send this class also. If there is anyother good way for this, just tell me. 
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:42:00+00:00Added an answer on June 13, 2026 at 10:42 pm

    (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:

    1. Serialize it to a byte stream.

    2. Encode that byte stream into a string (Base64 or similar).

    3. Send that encoded string to the server via ajax.

    4. Decode the string back into a byte stream on the server.

    5. 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send the events from one Java class to Activity. Scenario
Am trying to create a java project which can able to send push notification
I am trying to send a serialized Java object from a client to a
I created WSDL file and in the WS Client class am trying to send
I am trying to send Email using java mail API from with in a
I am trying to send the POST data from java to a PHP page.
I'm trying to send some data from c++ to java using JNI. In c++
I am trying to send an email with an image attachment from Java. I
I am trying to send Email from a Java program that I found here
I'm trying to send a broadcast from java on my mac. This seems like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.