[SOLVED] Trying to get started with JSP on Debian 5.0 (Lenny)
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
As far as I can tell, that should be (more than) enough to get started, but I'm at a complete loss how I should configure this. There is a lot of information out there, but I haven't found anything that clearly explains how to configure apache and tomcat to get this to work.
I've added a sample file (index2.jsp) to the default /var/www directory; instead of interpreting the code, it just displays it though.
For now, it's enough to get everything working on the default site - I'm not too worried about security or running multiple sites (yet) as I'm just trying stuff out on a virtual machine.
As an additional note, I'm planning to use the jsp pages together with postgresql - are there any additional packages I should install for that (besides the obvious postgresql?)
Thanks, that article's a great help - the link for tomcat seems broken, though (http://tomcat.apache.org/download-55.cgi) - any alternatives to download it? (it might be a temporary problem, I'll try again later)
Thanks, I was able to download it now - I'm afraid I've done something wrong, though - still isn't working (http://localhost by default opens index.html instead of index2.jsp, and when I open http://localhost/index2.jsp, I get the exact contents of the file (including the html tags) displayed in my browser.
Apache and tomcat both start without warnings or error messages, and i can't see anything out of the ordinary in the logfiles.
(I'll probably be trying again tonight, have some other stuff to do now)
Last edited by MHJCuijpers; 09-20-2010 at 03:39 AM.
Reason: afk
If I run a2enmod jk, I get the message 'Module jk already enabled'. So that was on.
I had already added the following to /etc/apache2/apache2.conf:
Code:
# Enable Jk for all sites
JkMount /* default
JkMount /*.jsp default
# Look for index.jsp first, then index.html
DirectoryIndex index2.jsp index.html
# Globally deny access to the WEB-INF directory
<LocationMatch '.*WEB-INF.*'>
# Onderstaande regel kreeg warning 'Useless use of AllowOverride'
# AllowOverride None
deny from all
</LocationMatch>
I'm not 100% sure if I did that correctly, but I think so. So I've got both the JkMount and DirectoryIndex directives included.
This is used to pass he request for a jsp page to a worker named 'default'. If apache still shows the jsp code, it means that it does not do that, or you have to clean your browser's cache.
If you've followed the howto you need also to use the following in apache2.conf:
Code:
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk logs
JkLogFile /var/log/apache2/jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “
Stop both servers and then start tomcat first and apache afterwards.
# mod_jk config
# Where to find workers.properties
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk logs
JkLogFile /var/log/apache2/jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicate to send SSL KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
Which seems to do exactly the same thing as adding this code directly to the apache2.conf (this was suggested in one of the replies to the howto)
I moved the JkMount lines to /etc/apache2/sites-enabled/000-default
The DirectoryIndex now works correctly (I'm directed to index2.jsp instead of index.html). But, instead of a direct dump of the file, I now get a blank page.
Could this be my sample JSP code? My index2.jsp looks like this:
I'm not familiar with debian, but I guess /etc/apache2/mods-enabled/jk.conf is used just to load the mod_jk module. You better put the JK directives in apache2.conf, or inside the default vhost.
You can check if there is anything logged in /var/log/apache2/jk.log
Also what happens if you move index2.jsp into tomcat ROOT directory?
If I look in jk.log I see several messages like this one:
Code:
[Tue Aug 10 22:02:20 2010]default localhost 0.001496
I've tried moving the JK directives to apache2.conf and/or 000-default, but to no effect (I get an error message if I try to but them in both the jk.conf and apache2.conf)
Moving the files to the tomcat root sounds like a good idea, but I'm not sure which directory is the tomcat root. I've put both index2.jsp and index.html in /usr/share/tomcat5.5/webapps - still no success (blank pages for both of them by the way - I think this also happened earlier, but I didn't refresh the index.html properly)
Note that in the end I installed the tomcat5.5 package via apt-get, instead of via the download - although I got the download working in the end the package seems to have been improved since the howto was written. I should've mentioned this earlier I guess; I just noted that the latest problems I'm having might be related to the package being messed up (as mentioned in the how-to:
Quote:
the webapps directory is symlink’d under /var/, which tends to cause problems with Apache->Tomcat configuration.
). I'm going to try to remove the tomcat package installation and replace it with the manual install. I'll report back when I've tried that.
If I look in jk.log I see several messages like this one:
Code:
[Tue Aug 10 22:02:20 2010]default localhost 0.001496
This is 10 days old, unless your computer clock is 10 days back
For the default binary tomcat package you need to put the jsp pages in webapps/ROOT/ directory. I guess the blank page is maybe the tomcat 404-error page for debian
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.