Mixing JSP pages between Apache and Tomcat

E

euroq

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
 
S

Soren Kuula

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
 
E

euroq

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
 
J

Juha Laiho

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/ .
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top