How to enable tomcat support for an account created under Cpanel Server?
Quite simple. If you’re a server admin, Login to WHM and search for “Install Servlets” option. Select the domain name and click on Install.
Now, this feature will make the required configuration entires in Tomcat configuration file i.e /usr/local/jakarta/tomcat/conf/server.xml
It looks as follows :
docBase=”/home/domainna/public_html” debug=”0″/>
docBase=”/usr/local/jakarta/tomcat/server/webapps/manager”>
www.domainname.com
Along with this few more entries needs to be added to your servers configuration file related to apache mod_jk
module.
Following IfModule section is added inside the virtual host entry of the domain (here it is domainname.com please check server.xml entry which I mentioned earlier)
JkMount /*.do ajp13
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
JkMount /manager/* ajp13
For the above lines to work with Apache, you got to be sure that mod_jk
apache module is installed and loaded into Apache.
Search for following lines in httpd.conf
to confirm the same :
LoadModule jk_module libexec/mod_jk.so
AddModule mod_jk.c
Now, you’re ready to go ahead and restart apache and tomcat (PS: If you’re installing servlet from WHM, you need not restart tomcat)
You might notice that installing servlet via WHM added an a folder called WEB-INF
folder inside the document root of the domain (/home/domainna/public_html in the above example
). This folder can be used to organize your servlet classes and lib files. Your domains web.xml will also go into WEB-INF.
Now, lets put a test jsp file called jsptest.jsp
with the following code :
Test JSP page
Sample Application JSP Page
This is the output of a JSP page that is part of the Hello, World application.
It displays several useful values from the request we are currently
processing.
Request Method: <%= request.getMethod() %> Servlet Path: <%=
request.getServletPath() %>
Save the file and browse this jsp file from the browser now.
Ex: https://domainname.com/jsptest.jsp
Are you greated with the following message ?
Sample Application JSP Page
This is the output of a JSP page that is part of the Hello, World application.
It displays several useful values from the request we are currently processing.
Request Method: GET
Servlet Path: /jsptest.jsp
Kewl! Congratulations. Your Jsp file is working now.
Now go ahead and update your client.