Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

372
Vistas
sending images from java webserver to client

i'm new to java web App i was trying to create simple chat webapp that send images to webserver then the server will send them to other client at first i had problem that the websocket wont send large data so i send my images using

http request

after encoding them to base64 then after i was able to decode it and store it,i was trying to seend it from the server to the other client

i did not find any solution the only way to send it to the other client is using websocket

this is the third day of searching and i'm thinking of given up since there is no resources for noobies

i saw alot of code but they was in high level i hope if some one have the answer of

How can i send the image to the client ?

please Try to explain it in a simple way

the javascript function responsible for sending the img

send=function () {
    
               var file =document.getElementById("image").files[0];
    
    
               var content_type ={
                   headers:{
                       "content-type" : "multipart/form-data"
                   }
               };
    
                   var formdata = new FormData();
                   formdata.append('image',file);
    
                   axios.post('AddImage',formdata,content_type)
                       .then(function (response) {
                           console.log(response);
                       })
                       .catch(function (error) {
                           console.log(error);
                       });
    
           }

the post method that send the file

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        Part file=request.getPart("image");



        InputStream in = file.getInputStream();
        byte[] Byte_file = new byte[in.available()];
        in.read(Byte_file);



        String encodedString = "{encodedString : "+"data:image/png;base64,"+new String(Byte_file)+"}";

        //sending the String  to the  other client via his session
        socket.session.getAsyncRemote().sendText(encodedString);

    }
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda