aspose file tools*
The moose likes Tomcat and the fly likes what to expect from a tomcat provider Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "what to expect from a tomcat provider" Watch "what to expect from a tomcat provider" New topic
Author

what to expect from a tomcat provider

Phil Freihofner
Ranch Hand

Joined: Sep 01, 2010
Posts: 115
    
    1
Hi - I am new to Tomcat. I have it running on my home PC, and am using it with learning both some AJAX and some JSP/Servlet programming. I recently took the step of setting up my first account with an ISP to try out a web-app project I wrote which interacts with a MySQL database connection (works on home system). There are some unexpected aspects to the service being provided, and I am wondering if what I am being asked to do is normal, or if I should try and find a different ISP.

The WAR file does not automatically unpack. I have to FTP it to a webapps folder and unzip it myself, and I'm being asked to do my own setting of read/write permissions to the sub folders, such as WEB-INF. At home, though, I can create a .WAR export from Eclipse and drop it into the local webapps for Tomcat and it unpacks and runs just fine.

Right now, I'm just trying to run an example program from the Murach text on JSP/Servlets, not the full database program I wrote. The point where the program crashes is when it tries to determine a file name for writing a text file in the WEB-INF for the project. That's when I discovered the WEB-INF folder was giving the write command a "permission denied".

Prior to having a "webapps" folder set up in my FTP area, I was given something called a PLESK utility where I could drop the WAR file, and everything would run except the program gave a null when one tried to determine a local file name via a ServletContext object and create a text file in the WEB-INF folder. I strongly suspect the reason for the null was that the PLESK was not unpacking the WAR. Also, with the PLESK setup, we didn't have FTP access to the files, nor access to error log files.
So, I'm thinking maybe these folks at this ISP don't have a lot of Tomcat hosting experience?

Secondly, how does one go about finding an ISP? I can easily get a list of candidates via a web search, but I've emailed or called four and not gotten any return communications. Is this list an appropriate place to ask for references for a good Tomcat ISP?

With gratitude, as always,

Phil Freihofner
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

Actually, you have a bigger problem. Don't write files into your WAR!!![.

WARs aren't "supposed" to be unpacked according to the J2EE standard. They're supposed to be used "as is", and that means as a single read-only ZIP file.

Tomcat relaxes that requirement in that it can unpack (explode) WAR files or use pre-exploded WARs. And by default, if you drop a WAR into the TOMCAT_HOME/webapps directory, it will. If you set up an application context referencing a WARfile in some other directory, it generally won't. Operationally, the net results, whether exploded or unexploded should be the same.

Except for the matter of writing into a WAR, since WAR files are effectively read-only.

Actually, there's an even bigger reason why you shouldn't store mutable information in a WAR, even when you can. The normal update process for a WAR involves complete replacement of the entire WAR. If you have data written into your WAR, it's going to get nuked. Someone did this to me just last year, and I still haven't forgiven him.


Customer surveys are for companies who didn't pay proper attention to begin with.
Phil Freihofner
Ranch Hand

Joined: Sep 01, 2010
Posts: 115
    
    1
Actually, there's an even bigger reason why you shouldn't store mutable information in a WAR, even when you can. The normal update process for a WAR involves complete replacement of the entire WAR. If you have data written into your WAR, it's going to get nuked. Someone did this to me just last year, and I still haven't forgiven him.


Thanks for the heads up! To the extent I thought this through, I guess I was anticipating that I'd go into WEB-INF and manually copy/restore a file required for persistence. That's why I was surprised when I didn't have FTP access the initial Plesk setup. OK, at least with the current setup I can create my own directory structure at the FTP site and at the home mirror site and in Eclipse. If that works, I can settle with working with this ISP.
Phil Freihofner
Ranch Hand

Joined: Sep 01, 2010
Posts: 115
    
    1
The ISP has changed things around so that now when I deploy the WAR, it does expand. Also, the code which writes to the WEB-INF is now working, so the permissions issues around that must have cleared up. So, I now have an environment that matches my initial expectations, which I got from what seems to be a generally well-considered text book on the subject.

Backtracking a bit...

If one does have to use an unpacked WAR, what is the common practice if one wants to use a file (e.g., a text file) as persistent data storage? Where is the file put and how is that location addressed (using ServletContext?), and is it addressed the same way in the IDE, the test site and the site itself, or will code have to be modified for each location? Also, could the problem you encountered with the WAR wiping out a data file have been prevented via a backup system or a more explicit policy/procedure on doing updates? Or is there more to the tradeoff here than I am seeing. I am asking/observing from a position of considerable inexperience!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what to expect from a tomcat provider