How to Setup Tomcat Application+JSP in Different Path Outside Root?

I recently installed Bitnami Tomcat Stack and it runs fine.

However, I have Tomcat application that needs to run outside of the Tomcat ../webapp/ROOT folder. The folder I would like to put my application is in the path ../webapp/MYAPP instead.

I have set my application's docBase and work folders correctly so the Tomcat application can run fine. However, when I try to access .jsp files of my webapp using my web browser, I get a 404 not found error.

Is there a way to specify that the JSP files run from ../webapp/MYAPP instead?

Also, how would I access the JSP files?

http://myurl.com/MYAPP/somejsp.jsp with ajp proxy? Or http://myurl.com:8080/MYAPP/somejsp.jsp?

BTW -- I am also running PHP on the same server.

Thanks for any help you can give me.

Hi, I think this guide could helps for you: How to connect Apache server with Tomcat http://wiki.bitnami.com/Components/Apache_Tomcat#How_to_connect_Apache_server_with_Tomcat.3f

If you have your application in apache-tomcat/webapps/myapp, the application will be available at http://domain:8080/myapp. If you have an Apache server already running, you can use the AJP protocol to publish your application at http://domain/myapp.

Thanks Beltran for the help. I really appreciate it.

What is strange (and I've struggled with it on the Bitnami stack) is that if I custom install Tomcat, then my app runs just fine. On Ubuntu and on CentOS-- even on Windows.

But over on the Bitnami Stack, JSP files don't run properly with the application configuration I have.

Maybe these details can help:

My Stack and Application Folder Structure:

  1. I installed Tomcat stack into /opt/bitnami.
  2. The Tomcat folder is in /opt/bitnami/apache-tomcat.
  3. My application is in: /opt/bitnami/apache-tomcat/webapps/MyApp
  4. I have some test JSP files in: /opt/bitnami/apache-tomcat/webapps/MyApp/WEB-INF/jsp/test/

I have put a MyApp.xml into /opt/bitnami/apache-tomcat/conf/Catalina/localhost with the following:

<Context path="/MyApp" reloadable="true" docBase="/opt/bitnami/apache-tomcat/webapps/MyApp" workDir="/opt/bitnami/apache-tomcat/webapps/MyApp/work">
</Context>

In my ../MyApp/WEB-INF folder, there is an applicationContext.xml that uses spring framework and I have the following in the file:

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    <property name="prefix" value="/WEB-INF/jsp/"/>
    <property name="suffix" value=".jsp"/>
</bean>

All JSP files can be loaded from these folders:

/opt/bitnami/apache-tomcat/webapps/ROOT
/opt/bitnami/apache-tomcat/webapps/host-manager
/opt/bitnami/apache-tomcat/webapps/manager
/opt/bitnami/apache-tomcat/webapps/examples

And for my own app within MyApp folder, JSP can be loaded from these folders:

/opt/bitnami/apache-tomcat/webapps/MyApp
/opt/bitnami/apache-tomcat/webapps/MyApp/random_sub_folder

But JSP files won't run from:

/opt/bitnami/apache-tomcat/webapps/MyApp/WEB-INF
or any subfolder under WEB-INF

Any help would be greatly appreciated. I tried a lot of different combinations, but still stuck here.

Have you checked that the exact same configuration works on other Tomcat installation? The difference with the BitNami Tomcat stack is that is uses Apache as a front end. It is likely a configuration issue, have you check the Apache and Tomcat log files?

It was a user/permission issue. Sorry to bother you with this. Always something simple :-)

Hi you said that it is a user/permission issue. I am facing the same problem. Would you let me know the solution to the issue?. Regards.

Hello @rrdesai64,

Could you provide us with more details about the issue? Where are you placing your app? What SO are you using? Are you getting a 404 error too?

Also, have you checked that the exact same configuration works on other Tomcat installation? Bitnami Tomcat stack uses Apache as a front end, but you should not find another difference. Have you checked Apache and Tomcat log files?
https://docs.bitnami.com/installer/components/apache/#how-to-debug-errors-in-apache
https://docs.bitnami.com/installer/components/tomcat/#how-to-debug-errors-in-tomcat

Regards