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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:09:25+00:00 2026-05-19T04:09:25+00:00

Working on some import process where i need to first upload the file at

  • 0

Working on some import process where i need to first upload the file at some location on server and than later on i need to pick the file from this location to import it in to the system.
i am just wondering what might be the best place to store the uploaded file. i have few option

1) Can create a folder in the root of tomcat and than can place the upload files there and later on can pick the file for the import process.

File dir = new File(System.getProperty("catalina.base"), "uploads");

is this a good option and weather the above code will work equally in all enviornment

2) i can create an uploads folder undermy application and can access it for file upload and later on for import by using the following code

ServletActionContext.getServletContext().getRealPath("uploads");

your valuable suggestions are needed the only work i need to do is to upload the file and den run the import process for the uploaded files(s) and once import is successfull remove files from this folder to other like processed etc.

  • 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-05-19T04:09:25+00:00Added an answer on May 19, 2026 at 4:09 am
    File dir = new File(System.getProperty("catalina.base"), "uploads");
    

    It won’t work on environments where catalina.base property is absent. So you need to either document it properly in the installation manual of the webapp to ensure that this property is been set on the server machine in question, or to look for an alternative approach.


    ServletActionContext.getServletContext().getRealPath("uploads");
    

    This is not a good choice as permanent storage. Everything will get lost whenever you redeploy the WAR.

    Rather store it in a known and fixed path outside your webapp and add its path as <Context> in Tomcat’s /conf/server.xml so that it’s available online as well.

    If you don’t want to alter the Tomcat’s /conf/server.xml for some reason, then you need to create a servlet which reads the file from disk using FileInputStream and writes it to the OutputStream of the response. You can find here a basic example.

    Related questions:

    • Simplest way to serve static files from outside application server
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I'm having some serious issues here. I'm new to this site, and new
Using Pythons (2.7) 'json' module I'm looking to process various JSON feeds. Unfortunately some
I spent quite a while with Google to find some information on this topic,
I want to write a Scala script to recursively process all files in a
I'm currently working with MIDlets (I am using a Visual MIDlet) in Netbeans, and
I'm working to implement a workflow engine into my project and the main purpose
So i'm working with CakePHP v1.2.5. On my current project, I decided to start
I have a script, which contains some packages/modules. Now, the development and the production
A web project I'm coding for uses a complex CSV to MySQL converter to

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.