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 3331284
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:34:12+00:00 2026-05-17T23:34:12+00:00

I worked on a JSP code that is runnning on a Tomcat5.5 server in

  • 0

I worked on a JSP code that is runnning on a Tomcat5.5 server in windows system .

I had to copy all the JSP code to a linux system and when I did the same I got an error stating below.

 javax.servlet.ServletException: c:\tmp is not a directory
 Readcsv.init(Readcsv.java:36)
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)


org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
 org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
 org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
 org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
 java.lang.Thread.run(Thread.java:636)

I modified a java code in the windows system without that c:\tmp directory and restarted the tomcat server and the tool worked fine.

When I replaced the modified java code of windows to the linux system, I still get the same error.

Note: Am accessing the linux server from windows using the url http://192.168.0.85:8080/CNA/uploadcsv.jspwhere 85 is the system number of linux.

Is there anything like tomcat has to be restarted for the linux version too? If so how to do the same?

UPDATE

This is where I have used the c:\tmp location in my code.

public class Readcsv extends HttpServlet {
private static final String TMP_DIR_PATH = "c:\tmp";
private File tmpDir;
private static final String DESTINATION_DIR_PATH ="/files";
private File destinationDir;

public void init(ServletConfig config) throws ServletException {
    super.init(config);
    tmpDir = new File(TMP_DIR_PATH);
    if(!tmpDir.isDirectory()) {
        throw new ServletException(TMP_DIR_PATH + " is not a directory");
    }
    String realPath = getServletContext().getRealPath(DESTINATION_DIR_PATH);
    destinationDir = new File(realPath);
    if(!destinationDir.isDirectory()) {
        throw new ServletException(DESTINATION_DIR_PATH+" is not a directory");
    }

}

How can I find the replacement for the temp path? The destination path works fine.
I exactly copied the code from this example

  • 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-17T23:34:13+00:00Added an answer on May 17, 2026 at 11:34 pm

    Don’t hardcode disk file system paths in your code. That’s only portability and maintainability trouble.

    In case of temporary files, rather make use of File#createTempFile().

    File tempfile = File.createTempFile("name", ".ext");
    

    It will automatically create the temp file at the right location, regardless of the environment. You can however also obtain the tmp dir root location by System.getProperty("java.io.tmpdir");.


    In case of resources which are to be read by your application, just put them in the runtime classpath or add their path to the runtime classpath. Then you can just obtain them from the classpath by getResource() and getResourceAsStream() methods on Class or ClassLoader.

    InputStream input = getClass().getResourceAsStream("file.properties");
    

    If you really need to have a fixed path outside the classpath, then rather define it in a properties file so that you at least have any control over the path from outside the application (so, without the need to change the code everytime).

    String path = properties.getProperty("my.file.path");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to update my SQL lite database with the native update-method of
I am attempting to pull some information from my tnsnames file using regex. 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.