Hi John,

Ok, I'm going to try show you how I think about this stuff... and I'm often wrong ;)

Dont use a redirect... it goes back to the browser and its not cool.

Firstly make a servlet and have a look at the CONTEXT.XML file under META-INF

Change it to......
<?xml version="1.0" encoding="UTF-8"?>
<Context path=""/>

Now have a look at WEB.XML under WEB-INF

make sure the mapping is
   <servlet-mapping>
       <servlet-name>NewServlet</servlet-name>
       <url-pattern>/*</url-pattern>
   </servlet-mapping>

OK.... now that servlet will run for any URI from the domain name up ie www.host.com/ANYTHINGorNOTHING

You can play with the mapping if you dont want that... but let me show you how I do this sort of stuff, and then you can tweak it as you want.

Now in the servlet make this routine

protected void displayPage(HttpServletRequest request, HttpServletResponse response, String thePage)
   throws ServletException, IOException {

RequestDispatcher dispatch = request.getRequestDispatcher(thePage);
               dispatch.forward(request, response);
    }

Now when the servlet is called in
protected void processRequest(HttpServletRequest request, HttpServletResponse response)

do this

displayPage( request,  response,  "index.jsp");

So all of a sudden you can direct any URL to any page without redirects.... can use the API to check the URL and use a case statement whatever.

OK... heres the final trick coz it looks like you trying to run behind Apache

put this in the servlet.xml file in Tomcat.conf

   <Host name=www.site.com appBase="webapps"

   unpackWARs="true" autoDeploy="true"

   xmlValidation="false" xmlNamespaceAware="false">

<!-- USE THIS FOR AUTO GEN OF JK MOD for Apache Forwarding to tomcat MODIFY PATHS FOR YOUR SYSTEM-->

<Listener className="org.apache.jk.config.ApacheConfig" append="true" forwardAll="false" modJk="D:/DEV/Apache2.2/modules/mod_jk.so"/>



   </Host>

Now when you start Tomcat it will create a folder under conf/auto it puts all the stuff apache needs in a mod_jk.file

looks like this.... but its AUTOMATICALLY generated when tomcat starts.

   # Static files
   Alias /jsp-examples "D:/DEV/Tomcat 5.5/webapps/jsp-examples"

   <Directory "D:/DEV/Tomcat 5.5/webapps/jsp-examples">
       Options Indexes FollowSymLinks
       DirectoryIndex index.html index.htm index.jsp
   </Directory>


   # Deny direct access to WEB-INF and META-INF
   #
   <Location "/jsp-examples/WEB-INF/*">
       AllowOverride None
       deny from all
   </Location>

   <Location "/jsp-examples/META-INF/*">
       AllowOverride None
       deny from all
   </Location>
   #
# Use Directory too. On Windows, Location doesn't work unless case matches
   #
   <Directory "D:/DEV/Tomcat 5.5/webapps/jsp-examples/WEB-INF/">
       AllowOverride None
       deny from all
   </Directory>

   <Directory "D:/DEV/Tomcat 5.5/webapps/jsp-examples/META-INF/">
       AllowOverride None
       deny from all
   </Directory>

   JkMount /jsp-examples/security/protected/j_security_check  ajp13
   JkMount /jsp-examples/forward/one.jsp  ajp13
   JkMount /jsp-examples/tagplugin/foreach.jsp  ajp13
   JkMount /jsp-examples/dates/date.jsp  ajp13
   JkMount /jsp-examples/jsp2/tagfiles/panel.jsp  ajp13
   JkMount /jsp-examples/xml/xml.jsp  ajp13
   JkMount /jsp-examples/jsp2/simpletag/repeat.jsp  ajp13
   JkMount /jsp-examples/CompressionTest  ajp13
   JkMount /jsp-examples/cal/cal2.jsp  ajp13
   JkMount /jsp-examples/sessions/carts.jsp  ajp13
   JkMount /jsp-examples/tagplugin/choose.jsp  ajp13
   JkMount /jsp-examples/jsptoserv/jsptoservlet.jsp  ajp13
   JkMount /jsp-examples/jsp2/misc/config.jsp  ajp13
   JkMount /jsp-examples/checkbox/checkresult.jsp  ajp13
   JkMount /jsp-examples/security/protected/login.jsp  ajp13
   JkMount /jsp-examples/jsp2/simpletag/book.jsp  ajp13
   JkMount /jsp-examples/forward/forward.jsp  ajp13
   JkMount /jsp-examples/jsp2/jspx/textRotate.jspx  ajp13
   JkMount /jsp-examples/simpletag/foo.jsp  ajp13
   JkMount /jsp-examples/security/protected/index.jsp  ajp13
   JkMount /jsp-examples/include/include.jsp  ajp13
   JkMount /jsp-examples/error/err.jsp  ajp13
   JkMount /jsp-examples/jsp2/el/basic-arithmetic.jsp  ajp13
   JkMount /jsp-examples/*.jspx  ajp13
   JkMount /jsp-examples/jsp2/jspx/basic.jspx  ajp13
   JkMount /jsp-examples/snp/snoop.jsp  ajp13
   JkMount /jsp-examples/error/errorpge.jsp  ajp13
   JkMount /jsp-examples/jsp2/jspattribute/jspattribute.jsp  ajp13
   JkMount /jsp-examples/include/foo.jsp  ajp13
   JkMount /jsp-examples/jsp2/el/functions.jsp  ajp13
   JkMount /jsp-examples/jsp2/tagfiles/products.jsp  ajp13
   JkMount /jsp-examples/jsp2/simpletag/hello.jsp  ajp13
   JkMount /jsp-examples/jsp2/el/basic-comparisons.jsp  ajp13
   JkMount /jsp-examples/colors/colrs.jsp  ajp13
   JkMount /jsp-examples/jsp2/jspattribute/shuffle.jsp  ajp13
   JkMount /jsp-examples/num/numguess.jsp  ajp13
   JkMount /jsp-examples/*.jsp  ajp13
   JkMount /jsp-examples/plugin/plugin.jsp  ajp13
   JkMount /jsp-examples/source.jsp  ajp13
   JkMount /jsp-examples/servletToJsp  ajp13
   JkMount /jsp-examples/tagplugin/if.jsp  ajp13
   JkMount /jsp-examples/cal/cal1.jsp  ajp13
   JkMount /jsp-examples/jsp2/tagfiles/hello.jsp  ajp13
   JkMount /jsp-examples/jsptoserv/hello.jsp  ajp13
   JkMount /jsp-examples/jsp2/misc/dynamicattrs.jsp  ajp13
   JkMount /jsp-examples/security/protected/error.jsp  ajp13
   JkMount /jsp-examples/jsp2/el/implicit-objects.jsp  ajp13


THEN in a apache add

# I added this for jk connector jk is auto gen by tomcat======
Include "D:/DEV/Tomcat 5.5/conf/auto/mod_jk.conf"


Apache will use Tomcat and the servlet configuaration in Tomcat..... DONE!

Now even for load balancing I remove the Apache include but still leave the Autogeneration in tomcat because Tomcat generates the code and I can just copy and paste.

You'll find you can do anything.... and you should be able to because its a simple MVC model.

Now you going to tell me you have used Struts or Spring or something..... oh well, guess you'll have to ask the framework gods.... this is so easy I really cant understand why people use that stuff.

Hope this helps....

Good luck.



----- Original Message ----- From: "John Moore" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Tuesday, March 13, 2007 3:28 AM
Subject: How does one configure Plain host domain url to run web app?


(Tomcat 4.x)

I have the following url that runs an application (pseudo url for discussion only)


http://www.mydomain.com/mysite/thecontext

works fine..

I would like to configure it so that..

http://www.mydomain.com

gets me to the same place..

I can place a "redirect" html page at

http://www.mydomain.com/mysite/index.html

which redirects to

http://www.mydomain.com/mysite/thecontext

but have yet to get a plain

http://www.mydomain.com

to work.. I keep getting either the "No Context configured....." error or the dreaded index of the directory..

I've tried Aliaes, Document root, Directory, and various JkMount settings in the Virtual host conf file that seemed like it might work, but so far, no joy.. (Tried Googling it, but have not come up with the right key words..)

Some of the things I have tried  in the conf file..

==========================
Alias /mysite "usr/tomcat/webapps/mysite"
Alias / "usr/tomcat/webapps/mysite"

DocumentRoot "/usr/local/tomcat/webapps/mysite/"

<Directory "/usr/local/tomcat/webapps/mysite">
       Options Indexes FollowSymLinks
       DirectoryIndex index.html index.htm index.jsp
 </Directory>

   JkMount /mysite/thecontext  ajp13
   JkMount /mysite/*.jsp  ajp13

..variations of..
JkMount /*.jsp ajp13 -- gives me a dreaded index of the correct directory
  JkMount /*.html  ajp13  -- same as above
  JkMount /*.  ajp13  -- blank document (strange)
  JkMount /*  ajp13  -- context error


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to