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

  • Home
  • SEARCH
  • 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 8723267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:35:26+00:00 2026-06-13T07:35:26+00:00

I have an upload program which uploads file and saves it to the specified

  • 0

I have an upload program which uploads file and saves it to the specified host on which this application is deployed.

I want to save this files to other host.
Can someone guide me what changes I must do to my dispatcher servlet for the same or any other alternate?

  • 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-13T07:35:28+00:00Added an answer on June 13, 2026 at 7:35 am

    I Would advice to open a new connection with the other host within the Servlet and upload the file using the connection.

     int contentChar = null;
     FileInputStream inputStream = new FileInputStream(getfileRootDir()+ "/"+fileId));
    
     URL oracle = new URL("other server url");
     HttpURLConnection connection = (HttpURLConnection)url.openConnection();
     OutputStream outPutStream = connection.getOutputStrea()
     while ((contentChar = inputStream.read()) != -1) {
          outPutStream.write(contentLine );
     }
     inputStream .close();
     outPutStream.close(); 
     connection.close();
    

    If you want to use BufferredReader/Writer from efficiency perspective, you may want to write as below:

       String contentLine = null;
       BufferedReader reader = new BufferedReader(
                                        new FileReader(getfileRootDir()+ "/"+fileId));
    
       URL oracle = new URL("other server url");
       HttpURLConnection connection = (HttpURLConnection)url.openConnection();
       OutputStream outPutStream = connection.getOutputStrea()
       Writer streamWriter = new BufferedWriter(new OutputStreamWriter(outPutStream ));
       while ((contentLine = reader.readLine()) != null) {
            streamWriter.write(contentLine );
       }
       reader.close();       
       streamWriter.close();
       outPutStream .close(); 
       connection.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application which enables users to upload files. The files are
I have created a program which allows me to upload images to my server.
I have a upload text file field, and with it I plan to save
I am writing a program which lets me easily upload a file (drag file
I've written a small program which is able to upload files to a server
I have an system with which users can upload a CSV file via an
I am developing an application which uses file upload. My client uses Symantec End
I have been asked to upload my four programs which at the moment are
I have an upload box... <form action=upload_file.php method=post enctype=multipart/form-data><BR> <label for=file>Filename:</label><BR> <input type=file name=file
I have an upload form with a file to be uploaded. The issue I

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.