Něco takového jsem zkoušel, ale bez úspěchu co dělám špatně?
Servlet:
metoda service
ServletInputStream is = request.getInputStream();
int x;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while ((x=is.read())!=-1){
baos.write(x);
}
//ulozeni pole bytů
Aplikace:
FileInputStream fin = new FileInputStream("cesta_k_souboru");
URL u = new URL( "http://localhost:8080/WebModule1/upload2" );
URLConnection uc = u.openConnection();
uc.setDoOutput( true );
OutputStream out = uc.getOutputStream();
uc.connect();
int c;
while ((c=fin.read())!=-1){
out.write(c);
}
> Behalf Of Rastislav Rehák wrote:
>
> 1. aplikacia odosle data cez URLConnection
>
> 2. servlet ich precita cez request.getInputStream() .
>
>
>
> Martin Chalupa wrote:
>
> >Rád bych se zeptal jak realizovat spojení klasické java aplikace k
> >servletu? Aplikace odešle binární data a servlet by je měl uložit do
> >databáze.
> >
> >Martin Chalupa
> >
> >
> >