Hi Bikash,
From server side you first send the number of bytes the server wants to
deliver, then send the bytes from the server. I think this will help you.
-- Souvik Basak
Bikash Paul wrote:
> Hi all friends,
>
> Iam facing problem with updation of progressBar of my
> swing Interface.I want to update my progressBar by the
> bytes which is already written by server on
> destination.It is basically a uploading software.For
> that iam using a thread and i have written a method of
> taking the bytes from servlet.And in servlet iam
> writting bytes by 'PrintWriter' in loop.But I couldn't
> update progressBar.Can any one plz guide me where i am
> wrong in my code.If possible plz give me some code for
> that.Iam pasting those portion of codes only.Eagerly
> waiting for someone reply.
>
> In servlet:-
> ==========
> PrintWriter out=response.getWriter();
> for(cc = dis.read(buf, 0, 1024); cc > 0 ; cc =
> dis.read(buf, 0, 1024))
> {
> if(checkpath.exists()){
> os.write(buf, 0, cc);
> tot += cc;
> out.println(tot);
> if (str.equals(str1)) break;
> }
> else{
> out.println("Connection Broken");
> break;
> }
>
> Swing interface:-
> ===============
> public static void updateprogress(){
> int ln;
> int tot=0;
> String str;
> try{
> BufferedReader input = new BufferedReader (new
> InputStreamReader(con.getInputStream ()));
> while ((str=input.readLine())!=null)
> {
> ln=Integer.parseInt(str);
> tot += ln;
> progressBar.setValue(tot);
> }input.close();
> }
> catch(Exception exp) {
> System.out.println("Error:" + exp.toString());
> }
> }
>
> And Iam calling this method in my another method
> through which iam uploading file.
> myThread1 = new Thread (){
> public void run () {
> while (true) {
> updateprogress();
> try{
> this.sleep (10000);
> }
> catch(Exception nx){}
> }
> }
> };
> myThread1.start();
>
> Regards
> Bikash
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html