Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending serialized object from java program to servlet

I need to send a Java object from my Java program to Servlet. I thought of doing it by serialization. Is there any other thing I can use to send a Java object to Servlet. If it is by serialization can you give me the link for reference.

Thanks for the help

like image 668
Tivakar Avatar asked Sep 26 '26 03:09

Tivakar


1 Answers

Use an HttpURLConnection, create a POST request, and before connecting to the server, get the outputStream from the HttpURLConnection, wrap it with an ObjectOutputStream, and write your object to it.

You will have to do the reverse on the server side.

like image 174
MeBigFatGuy Avatar answered Sep 28 '26 17:09

MeBigFatGuy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!