Search code examples
apachejsptomcatdocument-root

Setting up Tomcat to process JSP's in DocumentRoot


I've got Apache running on my server, and some VHosts set up for myself through this; however, the apache documentRoot, nor any VHost's documentRoot appear to be calling tomcat to process any JSP files - in order to run a JSP, I need to upload it as a war archive, and access it via domain:8080.

Would anyone be able to point me in the right direction on getting tomcat set up so that it can process JSP files as normal?


Solution

  • Answering my own question on this, as neither solution offered what I was looking for.

    Firstly, I downloaded and compiled the apache mod jk_serv; following this, I configured a worker, under workers.properties with the following;

    workers.tomcat_home=/opt/apache-tomcat-7.0.50
    
    workers.java_home=/opt/jdk1.7.0_51/
    
    ps=/
    
    worker.list=ajp13_worker
    worker.ajp13_worker.port=8009
    worker.ajp13_worker.host=localhost
    worker.ajp13_worker.type=ajp13
    worker.ajp13_worker.lbfactor=1
    
    worker.loadbalancer.type=lb
    worker.loadbalancer.balance_workers=ajp13_worker
    

    Following this, under apache's conf.d, I set up a worker config to be loaded by apache, as follows;

    LoadModule jk_module modules/mod_jk.so
    
    JkWorkersFile /etc/httpd/conf/workers.properties
    JkLogFile     /var/log/httpd/mod_jk_log
    JkShmFile     /var/log/httpd/jk-runtime-status
    JkWatchdogInterval 60
    JkLogLevel    info
    
    JkMountCopy   All
    
    # all the contexts:
    JkMount        / worker1
    JkMount        /*.jsp worker1
    

    Finally, I set up a script that would update tomcat's server.xml, to add any relevant vHosts that were added to httpd.conf.

    With this, jsp files are now processed on-the-fly; without the need for uploading seperate WAR's.