If you are finding it complex - slow down. Build is a directory know to whomever wrote that build file. Ant assumes nothing about the file system.
May I suggest you take a moment to write down the steps involved in deploying your web app (i.e. compile and java source, war up the jsps etc., copy the file to the server etc.) and look at the available Ant tasks which can do the work for you? You might end up with an Ant file which looks something like this:
Of course as you get better with Ant you will discover there are far better ways of doing this. But try walking before you run.
Ritu Verma
Greenhorn
Joined: Jul 26, 2005
Posts: 10
posted
0
Hello Paul, Thanks for your patience!
I am making things crystal clear.
1.My Development Directory is D:\JavaProjects 2.Following is the structure of JavaProjects directory build.xml[the actual build script] ./src/jsp/hello.jsp ./src/html/index.html ./src/myapp.xml[to be used as the DD web.xml file] ./src/UserRegistrationServlet.java [servlet source code]
3.Following is the code snippet of my Ant build script (build.xml) <?xml version="1.0"?> <project name="MyProj" default="war" basedir=".">
4.And it worked, I have successfully created a WAR file. JavaRanch works!
5.But, my next query is that my Tomcat is installed in C:\jakarta-tomcat-5.5.9 directory. I don’t wanna manually move the WAR file to the webapps directory of my Tomcat installation. So, how can I use the copy Task to achieve the same. I thought of doing this:
6.Secondly, when I manually copied the MyProj.war file to the webapps directory of my Tomcat installation and restarted the container, I was glad to notice that the web.xml (DD) and servlet class file landed at the desired locations (inside WEB-INF, and WEB-INF/classes dirs respectively) But, The JSP and HTML page laded in the web app home i-e C:\jakarta-tomcat-5.5.9\webapps\MyProj\hello.jsp C:\jakarta-tomcat-5.5.9\webapps\MyProj\index.html
I though that it would land in the respective jsp and html folders. How can I do that?
Pls. help.....
Regards, Ritu SCJP
Ritu Verma
Greenhorn
Joined: Jul 26, 2005
Posts: 10
posted
0
Anybody there to help :roll: Ranchers pls. come foreward ...
Ritu Verma
Greenhorn
Joined: Jul 26, 2005
Posts: 10
posted
0
It looks like a dead thread. Anybody alive out there! I thought that JavaRanch is the best site to get answers to your Java related queries.
Ranchers pls. help.
Carol Enderlin
drifter
Ranch Hand
Joined: Oct 10, 2000
Posts: 1348
posted
0
Patience Ritu, patience. We're all volunteers around here and your post is really long.
I'll take a shot at your #6. You wanted your jsp stuff in a jsp directory and html stuff in an html directory. You'll need to tweak your filesets.
Now, I have successfully created a WAR file, and when I manually place that WAR file in my servlet container’s (Tomcat) webapps directory, restart Tomcat, things are located in the right directories as desired.
My next task is to copy the WAR file using the <copy> task. But, that requires hard coding the Tomcat root directory if my Tomcat is not installed in the ${basedir}.
This is what I do: <property name="tomcat" value="C:/jakarta-tomcat-5.5.9/webapps" />
<war …>
</war> …..
<copy todir="${tomcat}" file="${MyProj}.war" />
Although this works, but is there any other way I can copy the WAR file to the desired location?
Regards, Ritu SCJP
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35252
7
posted
0
The usual way to avoid hard-coding stuff in your build file is to put it in a properties file, which is then included in the build file. Check out the Ant Manual -> Using Ant -> Properties section; it explains how to go about that. Alternatively, if your Tomcat path is defined in an environment variable, then Ant can pick that up too (explained in the same section of the manual).
Actually, I don't copy the war file into Tomcat, I tell Tomcat to look for the war file in my project.
To do this, you set up an application Context - which I almost always have to do anyway, just for external control of database and other JNDI definitions. Although you can do this in server.xml, this is discouraged in favor of placing the Context definition in its own file (in Tomcat 5, that's TOMCAT_HOME/conf/Catalina/localhost/).
When you set up the context's docBase, you can point it to a WAR in your Ant project OR to an exploded WAR in your Ant project. An exploded WAR is good for quick debugging if you remember to back-propagate whatever changes you do there to the project sources from which it was build.
Customer surveys are for companies who didn't pay proper attention to begin with.
Ritu Verma
Greenhorn
Joined: Jul 26, 2005
Posts: 10
posted
0
Thanks All! I would like to thank all the Ranchers who posted here.... It was indeed a gr8 help
I copied the WAR file to my Tomcat Installation directory by using a properties file.