Mixing JSP pages between Apache and Tomcat

Discussion in 'Java' started by euroq, Aug 22, 2006.

  1. euroq

    euroq Guest

    Hello all. I am just starting this project for my company. I already
    have a web directory that is running on my company's server with
    Apache. I needed to have some dynamic content going on, and PHP was
    unfortunately not an option because I needed PHP-MySQL and the Linux
    distribution on the server is dated (RedHat 8.0) and I couldn't for the
    life of me find the compatible PHP-MySQL .RPM with the right
    dependencies.

    So... I installed Tomcat and mod_jk. In the httpd.conf for Apache, I
    have here:
    # Send everything ending with .jsp to worker named worker1 (ajp13)
    JkMount /*.jsp worker1

    Well I figured out that when mod_jk sends the requests over to Tomcat,
    Tomcat expects the .jsp files to be stored _IN_ Tomcat's directory.
    Which already presents a problem, because now I have to deploy from one
    directory structure to multiple locations. (Does anybody have another
    suggestion?)

    Besides that, here is my problem:
    I have this test page "test.jsp" in my root apache directory. The url
    is
    http://my.domain.com/test.jsp

    I copied "test.jsp" to the Tomcat directory:
    TOMCAT_DIR/webapps/ROOT/

    And it worked great. But when I have the url:
    http://my.domain.com/subdir/test.jsp
    And "test.jsp" is copied to the Tomcat directory:
    TOMCAT_DIR/webapps/subdir/
    Tomcat gives me a 404 (Not Found) error!

    How do I have .jsp pages in subdirectories with Tomcat? From what I
    can see, the only things in the Tomcat directories are webapps, i.e.
    they all have WEB-INF/web.xml files and each webapp is probably stored
    in another large .XML file. This seems overly complicated, as all I
    need is a simple .JSP page to be processed.

    Thanks for any help out there universe,
    -euroq
    euroq, Aug 22, 2006
    #1
    1. Advertising

  2. euroq

    Soren Kuula Guest

    euroq wrote:

    Hi, just a naive suggestion:

    > JkMount /*.jsp worker1


    > Tomcat gives me a 404 (Not Found) error!


    Did you not only map everything in the server ROOT to Tomcat? And is it
    really really Tomcat and not Apache that gives you the 404?

    Usually, just throwing a .jsp in webapps/something/blah.jsp should work
    without further ado...

    What happens if you make Tomcat accessible through a local port (like
    8080) (I can't remember the details, but Tomcat comes configured for
    that by default anyway) and access your jsp through that?

    Søren
    Soren Kuula, Aug 22, 2006
    #2
    1. Advertising

  3. euroq

    euroq Guest

    Hello all. I found the answer and am posting it for anyone else who
    may need it.

    > I have this test page "test.jsp" in my root apache directory. The url is
    > http://my.domain.com/test.jsp
    >
    > I copied "test.jsp" to the Tomcat directory:
    > TOMCAT_DIR/webapps/ROOT/
    >
    > And it worked great. But when I have the url:
    > http://my.domain.com/subdir/test.jsp
    > And "test.jsp" is copied to the Tomcat directory:
    > TOMCAT_DIR/webapps/subdir/
    > Tomcat gives me a 404 (Not Found) error!
    >


    The answer is to put "test.jsp" in
    TOMCAT_DIR/webapps/ROOT/subdir/
    which points to
    http://my.domain.com/subdir/test.jsp
    euroq, Aug 24, 2006
    #3
  4. euroq

    Juha Laiho Guest

    "euroq" <> said:
    >Hello all. I am just starting this project for my company. I already
    >have a web directory that is running on my company's server with
    >Apache. I needed to have some dynamic content going on, and PHP was
    >unfortunately not an option because I needed PHP-MySQL and the Linux
    >distribution on the server is dated (RedHat 8.0) and I couldn't for the
    >life of me find the compatible PHP-MySQL .RPM with the right
    >dependencies.


    Ok; how about dropping Apache and moving also the static content into
    Tomcat? Just a suggestion, but depending on your loads, might be one
    possibility.

    >Well I figured out that when mod_jk sends the requests over to Tomcat,
    >Tomcat expects the .jsp files to be stored _IN_ Tomcat's directory.


    However, also that directory is configurable. On the other hand, also
    the document root for Apache is configurable.

    >Which already presents a problem, because now I have to deploy from one
    >directory structure to multiple locations. (Does anybody have another
    >suggestion?)


    So, you can arrange for the Apache document root and Tomcat webapp
    directory be the same. Be careful with permissions, though - you
    should configure Apache to deny any and all downloads from the WEB-INF/
    directory tree.

    >Besides that, here is my problem:
    >I have this test page "test.jsp" in my root apache directory. The url
    >is
    >http://my.domain.com/test.jsp
    >
    >I copied "test.jsp" to the Tomcat directory:
    >TOMCAT_DIR/webapps/ROOT/
    >
    >And it worked great. But when I have the url:
    >http://my.domain.com/subdir/test.jsp
    >And "test.jsp" is copied to the Tomcat directory:
    >TOMCAT_DIR/webapps/subdir/
    >Tomcat gives me a 404 (Not Found) error!


    How about using webapps/ROOT/subdir/test.jsp? You really don't want to
    sprinkle your dynamic content into several webapps (which would happen
    if you used several subdirs within webapps/ .
    --
    Wolf a.k.a. Juha Laiho Espoo, Finland
    (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
    PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
    "...cancel my subscription to the resurrection!" (Jim Morrison)
    Juha Laiho, Sep 2, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christos Gravvanis
    Replies:
    0
    Views:
    2,031
    Christos Gravvanis
    Jul 7, 2004
  2. twins
    Replies:
    1
    Views:
    5,831
  3. Marcin Cenkier
    Replies:
    1
    Views:
    5,386
    Marcin Cenkier
    Apr 12, 2006
  4. Replies:
    0
    Views:
    4,332
  5. Andi
    Replies:
    5
    Views:
    1,318
Loading...

Share This Page