Re: Setting /WebContent as ROOT for an application
To add to what Alan said: If I create a new Eclipse Dynamic Web Project, and name it MyWebApp during the project setup, in the first window it has a drop down for Target Runtime. That should be your installed Tomcat on your desktop development machine; Windows in my case. It starts out with so click the New button next to it and select, for example, Apache Tomcat v6.0, and then in the next window use the Browse button to navigate to where Tomcat is installed (C:\Program Files\Apache Software Foundation\apache-tomcat-v.0.18 for me). You can leave the rest alone and click Finish. Next in Eclipse, do Window -> Show View -> Servers. That creates a Servers view window (tab) somewhere. Click on its tab to bring it forward, then right click in the Servers window and select New -> Server (strange that we have to do this again, but at least it's abbreviated this time), and select Tomcat v6.0 Server (or whatever you selected when you created the project). Then you get the Add and Remove Projects window; double click on MyWebApp to move it to the right into Configured projects, and click Finish. As per the DOS tree command my Eclipse project folder/file structure is then | .classpath | .project | +---.settings | .jsdtscope | org.eclipse.jdt.core.prefs | org.eclipse.jst.common.project.facet.core.prefs | org.eclipse.wst.common.component | org.eclipse.wst.common.project.facet.core.xml | org.eclipse.wst.jsdt.ui.superType.container | org.eclipse.wst.jsdt.ui.superType.name | +---build | \---classes +---src \---WebContent +---META-INF | MANIFEST.MF | \---WEB-INF | web.xml | \---lib You can ignore .classpath, .project, and .settings. If you check your project into Subversion, I recommend telling it to ignore those files; some people prefer checking them in. I completely ignore the contents of the build folder; whenever you do a clean in Eclipse it wipes and removes that folder. The folder of interest for me is the WebContent folder; its layout and contents is what will ultimately be in Tomcat as /usr/local/tomcat/webapps/MyWebApp (sorry, switching to Unix parlance there). This means that any jar files your project needs go in WebContent/WEB-INF/lib. Also, you should create the folder WebContent/WEB-INF/classes and put in it those things that need to be "on the classpath", for example, your logging config file (e.g., logback.xml or log4j.xml, or log4j.properties if you prefer that confusing format), and any other properties files and whatnot. It's instructive to do as Alan says and do the Eclipse export to war and then list the war file with a zip program to see what it's going to look like when Tomcat explodes it. Static jsp files will go directly in the WebContent folder (e.g., index.jsp). Dynamic jsp files will probably go in some subdirectory of WEB-INF; for example, I use Spring and I've configured it to look for the "views" in WEB-INF/views/jsp, with even more folders in that if I'm using something like Tiles. Back in Eclipse, in the Servers tab/window, is an entry for Tomcat, and the controls for that are at the top of the tab; the green circle arrow starts Tomcat and when it's started the red square stops it. In theory, and perhaps in practice, you can edit your .java files and do a compile/build in Eclipse and Tomcat will automatically reload them. I'm superstitious from back in the day when that didn't always work and try to remember to stop Tomcat before I do a build. This implies that I have Eclipse configured to not automatically build when I do a Save on a file. If Tomcat does get wedged in Eclipse; for example, changes stop showing, you can simply delete the Tomcat instance from Eclipse by right clicking on it in the Servers window/tab and selecting Delete, then re-add it and add your project to it. Note that when you start and run Tomcat from within Eclipse it's not deploying your project to your installed Tomcat; it's using the installed Tomcat's jar files and copying/creating its own Tomcat configuration files into your project space and running it all in there. It's all rather magical and, surprisingly, given all the apparent black magic, works quite nicely. It gets even more black magical if you use Maven and use the m2eclipse Maven plugin for Eclipse, but I think it's really worth it to climb that mountain because it gives you a great base for a consistent and maintainable project structure. Alan Chaney wrote: In Eclipse, assuming you have the WTP tools installed, you create a 'Dynamic Web Project.' This has a folder structure of which the essence is: MyApp src com mypackage Abc.java build com mypackage Abc.class WebContent index.html (or jsp or whatever) WEB-INF web.xml
Re: Setting /WebContent as ROOT for an application
In Eclipse, assuming you have the WTP tools installed, you create a 'Dynamic Web Project.' This has a folder structure of which the essence is: MyApp src com mypackage Abc.java build com mypackage Abc.class WebContent index.html (or jsp or whatever) WEB-INF web.xml lib a.jar b.jar In the above com.mypackage.Abc.java is your web application, and a.jar and b.jar are any runtime libraries that application requires (NOT stuff already in $TOMCAT_HOME/lib) When you compile and run applications within eclipse it copies the WebContent structure to the webapps directory of its (internal) tomcat, and in WEB-INF creates a folder called classes and copies the contents of the 'build' folder their. This normally happens automatically every time you start the server inside eclipse. When you want to deploy the project to an external instance of tomcat (eg a production server) you right-click on the Export.. option in the project context menu and then select WAR (there's a suprise). The war file by default has the project name (in the above expample MyApp.war. This should be copied to the webapps folder of the tomcat instance and if you've stuck to the normal server.xml configuration it should deploy. It will be available at http://the.tomcat.instance:8080/MyApp/index.html (or jspt or whatever) This is an incredibly brief summary of what is undoubtedly an obscure and complex process for the new-comer (been there.. done that...) and which sadly is not especially well EXPLAINED anywhere that I have found. There are some 'cookbook' type recipes on the web, which are often inconsitent. Hope that helps Alan Chaney (a daily eclipse user, but hardly an eclipse guru...) Markus Schönhaber wrote: Tom Blank: The reason why I'm asking is, because I'm using eclipse and its 'dynamic web project' structure. I'm no Eclipse user either, but AFAIR the folder "Webapps" is part of an Eclipse Dynamic Web Project. And a project folder is not meant to be simply copied to Tomcat's appBase (judging from your OP, it seems to me that's what you've been doing). You could, for example, export your project to a WAR file and deploy this. Experienced Eclipse users may know of other/better ways of deployment. You might consider asking in the appropriate Eclipse mailinglist/newsgroup. Regards mks - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org !DSPAM:4943f4d3100632009820482! - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Setting /WebContent as ROOT for an application
Tom Blank: > The reason why I'm asking is, because I'm using eclipse and its > 'dynamic web project' structure. I'm no Eclipse user either, but AFAIR the folder "Webapps" is part of an Eclipse Dynamic Web Project. And a project folder is not meant to be simply copied to Tomcat's appBase (judging from your OP, it seems to me that's what you've been doing). You could, for example, export your project to a WAR file and deploy this. Experienced Eclipse users may know of other/better ways of deployment. You might consider asking in the appropriate Eclipse mailinglist/newsgroup. Regards mks - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: RE: Setting /WebContent as ROOT for an application
> From: Tom Blank [mailto:blank-...@gmx.net] > Subject: Re: RE: Setting /WebContent as ROOT for an application > > The reason why I'm asking is, because I'm using eclipse and > its 'dynamic web project' structure. I'm not an Eclipse user, so I can't really help you in how to properly set up projects there. However, there are many who do use Eclipse with Tomcat and do not report the problem you have, so I have to think it's something misconfigured in your Eclipse project. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: RE: Setting /WebContent as ROOT for an application
Thanks Chuck for you Mail! The reason why I'm asking is, because I'm using eclipse and its 'dynamic web project' structure. For me actually I don't really care if it's on top or in some 'WebContent' directory. I just didn't want to change the structure every time I want to run/deploy my application. I thought that Tomcat is by default so configured that the ROOT is mapped to 'WebContent' but somehow not in my case. Tom Original-Nachricht > Datum: Sat, 13 Dec 2008 10:04:06 -0600 > Von: "Caldarale, Charles R" > An: Tomcat Users List > Betreff: RE: Setting /WebContent as ROOT for an application > > From: Tom Blank [mailto:blank-...@gmx.net] > > Subject: Setting /WebContent as ROOT for an application > > > > For Example: > > http://localhost:8080/myApp/ > > > > should point to this directory: > > C:/Server/Tomcat/webapps/myApp/WebContent/ > > > > where my index.jsp is located. > > This is not a "property" setting - it's the way it's supposed to work. > The directory structure *you* choose for your webapp is reflected in the URLs > that must be used to access that webapp. > > 1) Why do you have a hierarchy here? Is there something in the myApp > directory other than WebContent? Does this directory structure serve any > purpose? > > 2) If you must maintain this hierarchy, move your index.jsp file to myApp > from myApp/WebContent. > > 3) If you can't collapse the directory structure or move the index.jsp > file, then put a dummy index.html file in myApp that redirects to the proper > one (or use a filter to do the same thing). > > - Chuck > > > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY > MATERIAL and is thus for use only by the intended recipient. If you received > this in error, please contact the sender and delete the e-mail and its > attachments from all computers. > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org -- Sensationsangebot verlängert: GMX FreeDSL - Telefonanschluss + DSL für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K1308T4569a - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Setting /WebContent as ROOT for an application
> From: Tom Blank [mailto:blank-...@gmx.net] > Subject: Setting /WebContent as ROOT for an application > > For Example: > http://localhost:8080/myApp/ > > should point to this directory: > C:/Server/Tomcat/webapps/myApp/WebContent/ > > where my index.jsp is located. This is not a "property" setting - it's the way it's supposed to work. The directory structure *you* choose for your webapp is reflected in the URLs that must be used to access that webapp. 1) Why do you have a hierarchy here? Is there something in the myApp directory other than WebContent? Does this directory structure serve any purpose? 2) If you must maintain this hierarchy, move your index.jsp file to myApp from myApp/WebContent. 3) If you can't collapse the directory structure or move the index.jsp file, then put a dummy index.html file in myApp that redirects to the proper one (or use a filter to do the same thing). - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Setting /WebContent as ROOT for an application
Hi! I have a tiny problem, but can't figure out how the hell set my entry point of the application to /WebContent. For Example: http://localhost:8080/myApp/ should point to this directory: C:/Server/Tomcat/webapps/myApp/WebContent/ where my index.jsp is located. By default the ROOT of the application is set to /myApp instead of /myApp/WebContent. Please, help me. I don't know where to set this property so it's pointing to the correct directory. I'm using Tomcat 6.0 Thanks, Tom -- Sensationsangebot verlängert: GMX FreeDSL - Telefonanschluss + DSL für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K1308T4569a - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org