> quick question: > how do I map a servlet to a URL using mod_jk > eg I have /MyApp/WEB-INF/classes/dir1/dir2dir3/MyServlet.class > and I want that to http://host/MyApp/MyServlet
It can get really confusing to get all of this mess straight.... You need to do three things: 1 - Let Tomcat know about webapp 2 - Let Tomcat know about that particular servlet within the webapp. 3 - Let Apache know about the webapp STEP 1 ===== Probably the easiest way would be to use <AutoWebApp dir="/" host="some.virtual.host" /> This should generate most of the JkMount commands and stuff in mod_jk.conf... which you should be including in your Apache config from httpd.conf. There are a couple of problems with this method, though. First, directories for AutoWebApp are supposed to be relative to Tomcat's home dir. So, I doubt that you can really specify a directory in the root of your filesystem like you have there. You may have to move your "MyApp" directory to something below Tomcat's home.... usually $TOMCAT_HOME/webapps is where you'd put it. In fact, your stock Tomcat server.xml probably already has an AutoWebApp for that directory... in which case it should just automatically find and include your webapp the next time you restart Tomcat. The second problem is that, with AutoWebApp, Tomcat will try to create a webapp for every directory there that it finds. If you have "MyApp" in your root of your filesystem, I think Tomcat will try to make a webapp for /etc, /usr, /home, /var.... it would probably get a little ugly. STEP 2 ===== Now, recall that you've got: /MyApp/WEB-INF/classes/dir1/dir2dir3/MyServlet.class that you want mapped to: http://host/MyApp/MyServlet This is configured in your /MyApp/WEB-INF/web.xml file. You need to add two things. First, you need to give an internal name to a class file that will behave as a servlet: <servlet> <servlet-name> some-servlet-name-that-tomcat-uses-internally </servlet-name> <servlet-class> dir1.dir2.dir3.MyServlet </servlet-class> </servlet> Then, you tell Tomcat that you want a certain URL pattern to invoke that servlet that you just gave a name to. <servlet-mapping> <servlet-name> some-servlet-name-that-tomcat-uses-internally </servlet-name> <url-pattern> /MyServlet </url-pattern> </servlet-mapping> STEP 3 - Making Apache pass the appropriate stuff to Tomcat.... ===== You do this with "JkMount" in your Apache config files. Look in the mod_jk.conf that Tomcat should have generated. (If it didn't geenerate it, then read about the "ApacheConfig" directive for server.xml.). You should see something along the lines of: JkMount /MyApp ajp13 JkMount /MyApp/* ajp13 If you don't see these in any files that Apache is looking in, then I think you'll need to add them. They tell Apache which URL patterns to forward to Tomcat. Note, you probably also want a server-wide JkMount for "*.jsp" so that all JSP pages get processed by Tomcat. Hope this helps... - Joe -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>
