Pergunta

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?

Foi útil?

Solução 2

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.

Outras dicas

If I understand you correctly, you want to have JSP deployed outside of a war/webapps. Unfortunately, Tomcat does not work that way. You have to deploy your JSP as a WAR/folder-in-webapps. Unlike PHP or some such language plugin, Tomcat hosts Java apps. It does not process JSP files.

To get pass through, have you tried the mod_jk or as it is known now, the connector? http://tomcat.apache.org/connectors-doc/miscellaneous/faq.html

You simply need to copy your WAR file into the $TOMCAT/webapps/ folder and define a context in server.xml (or context.xml) for it, so it points to the root. in server.xml, contexts are defined inside a <Host>.

I would also advise you to remove the ROOT folder under $TOMCAT/webapps/ if any has been created.

Below an example of context definition:

<Host name="192.168.0.251"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
<Alias>myhost.mydomain.com</Alias>
<Context docBase="myWarFileName" path="" reloadable="true" source="myWarFileName">

... Add any resource, etc.. for this context here, if any ...

</Context>
</Host>

Note the empty path value, pointing then to the root directory. In some cases I have had to use "/" instead of an empty string.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top