wood burning stoves 2.0*
The moose likes Tomcat and the fly likes change default directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "change default directory " Watch "change default directory " New topic
Author

change default directory

tushar panda
Ranch Hand

Joined: Feb 16, 2009
Posts: 133
hi ,
i want to change tomcat default directory. i am working on a program where i have to pass form data to servlet .

my form data folder:
C:\apache-tomcat-6.0.20\webapps\ROOT\form-data


my servlet folder:
C:\apache-tomcat-6.0.20\webapps\ROOT\WEB-INF\classes



i want to change both the form-data folder & servlet folder to a different location like
C:\apache-tomcat-6.0.20\webapps\ROOT\mydir


in this folder i want to keep both my form-data and classfiles.

how can i change it. explain briefly.



Do Right , Fear No Man
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

Well, you can't. And you shouldn't, either. Why should Tomcat's current working directory be inside one of the possibily several web applications it controls?

Perhaps you should describe your actual problem. Tomcat's working directory should not have anything to do with your question.
tushar panda
Ranch Hand

Joined: Feb 16, 2009
Posts: 133
Paul Clapham wrote:Perhaps you should describe your actual problem.


i mean , now i am working on a resume creation project so i want to have different folder where i can keep all my data .
besides it is also better to have own directory rather than using tomcat's default servlet directory.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61767
    
  67

Yes, but again, what does that have to do with any concept of a "current directory"? Describe your problem, not a solution.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
tushar panda
Ranch Hand

Joined: Feb 16, 2009
Posts: 133
i have two files threeparamsform.html and threeparams.class in trp folder with path
C:\apache-tomcat-6.0.20\webapps\ROOT\trp


threeparamsform.html


threeparams.java


my problem:

when i enter data at this url


it comes to this url


and gives error this :


what went wrong
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

OK, repeat after me, children:

A web server is not a file server
A web server is not a file server
A web server is not a file server

A file server is a place where you can read and write files via ordinary filesystem I/O calls. A web server is a place where you send HTTP requests and get HTTP responses. Web URLs may look like file directory tree references, but it's only appearances, not reality. If the application running in the web server wants to root around the components of its WAR and return resources using the URL as a model, it may do so. However, if it chooses to do something entirely different, it can do that, too.

The one thing I'll say for certain, because somebody burned me quite badly on this within the last 6 months is that you should never upload files into a WAR. Firstly, because unless the WAR is an exploded WAR, there's no directories to upload into; J2EE doesn't support replacing parts of a WAR file.

Secondly - and this is where I got burned - even in the case of an exploded WAR, a redeployment of the webapp is likely to wipe out all those uploaded files.

There's nothing wrong with uploading files. Just upload them to a designated data directory, and not to an internal location in the webapp. You can hard-code a directory path into the app if you must, but personally, I prefer to make the upload directory a resource defined in web.xml, where JNDI can look it up and Tomcat can override it if it needs to.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: change default directory