LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 09-17-2010, 06:52 AM   #1
MHJCuijpers
LQ Newbie
 
Registered: Aug 2007
Location: Zevenaar, the Netherlands
Distribution: Debian 5.0 (Lenny)
Posts: 11

Rep: Reputation: 0
Trying to get started with JSP on Debian 5.0 (Lenny)


I am trying to get started with JSP on my Debian server. So far, I have installed the following packages:

apache2
openjdk-6-jdk
tomcat5.5
tomcat5.5-admin
libapache2-mod-jk

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?)
 
Old 09-17-2010, 01:22 PM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,897

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Hi,

I hope this howto, written for Debian, should help you go.

Regards
 
1 members found this post helpful.
Old 09-20-2010, 02:46 AM   #3
MHJCuijpers
LQ Newbie
 
Registered: Aug 2007
Location: Zevenaar, the Netherlands
Distribution: Debian 5.0 (Lenny)
Posts: 11

Original Poster
Rep: Reputation: 0
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)
 
Old 09-20-2010, 03:10 AM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,897

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Hi,

If you still have problems, you can download it directly from here

Regards
 
1 members found this post helpful.
Old 09-20-2010, 03:38 AM   #5
MHJCuijpers
LQ Newbie
 
Registered: Aug 2007
Location: Zevenaar, the Netherlands
Distribution: Debian 5.0 (Lenny)
Posts: 11

Original Poster
Rep: Reputation: 0
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
 
Old 09-20-2010, 03:58 AM   #6
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,897

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Looks like apache does not know how to handle jsp pages.
Make sure you've enabled mod_jk, i.e you ran:
Code:
a2enmod jk
and you have the following in apache's configuration
Code:
JkMount /* default
JkMount /*.jsp default
Without those, apache cannot pass .jsp pages to tomcat

Regarding index2.jsp, if you want apache to use it an an index page, you should add it in the DirectoryIndex directive.
 
1 members found this post helpful.
Old 09-20-2010, 04:58 AM   #7
MHJCuijpers
LQ Newbie
 
Registered: Aug 2007
Location: Zevenaar, the Netherlands
Distribution: Debian 5.0 (Lenny)
Posts: 11

Original Poster
Rep: Reputation: 0
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.
 
Old 09-20-2010, 05:38 AM   #8
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,897

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Quote:
JkMount /*.jsp default
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.
 
1 members found this post helpful.
Old 09-20-2010, 06:32 AM   #9
MHJCuijpers
LQ Newbie
 
Registered: Aug 2007
Location: Zevenaar, the Netherlands
Distribution: Debian 5.0 (Lenny)
Posts: 11

Original Poster
Rep: Reputation: 0
I created /etc/apache2/mods-enabled/jk.conf :
Code:
# 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:
Code:
<html>
	<head>
		<title>JSP Index</title>
	</head>
	<body>
		<div>Some text</div>
		<div><%="Some JSP generated text" %></div>
	</body>
</html>
The reason I know the file is being interpreted is that if I approach http://localhost/index.html I still get a valid page, and if I approach http://localhost/index3.php I get an error message - I just get a blank for http://localhost/ and http://localhost/index2.jsp

Last edited by MHJCuijpers; 09-20-2010 at 07:09 AM. Reason: clarification
 
Old 09-20-2010, 07:36 AM   #10
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,897

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
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?
 
Old 09-20-2010, 08:37 AM   #11
MHJCuijpers
LQ Newbie
 
Registered: Aug 2007
Location: Zevenaar, the Netherlands
Distribution: Debian 5.0 (Lenny)
Posts: 11

Original Poster
Rep: Reputation: 0
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.
 
Old 09-20-2010, 09:04 AM   #12
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,897

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Quote:
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
 
1 members found this post helpful.
Old 09-23-2010, 02:08 AM   #13
MHJCuijpers
LQ Newbie
 
Registered: Aug 2007
Location: Zevenaar, the Netherlands
Distribution: Debian 5.0 (Lenny)
Posts: 11

Original Poster
Rep: Reputation: 0
The computer clock actually is 10 days back; it's a virtual machine and the time sync isn't working properly.

Going to try so things again today; I'll post the results when I get them.
 
Old 09-23-2010, 03:01 AM   #14
MHJCuijpers
LQ Newbie
 
Registered: Aug 2007
Location: Zevenaar, the Netherlands
Distribution: Debian 5.0 (Lenny)
Posts: 11

Original Poster
Rep: Reputation: 0
webapps/ROOT actually didn't exist, so I created it and added the files there - it works now, thanks for helping me to get started!

I also added NTP so my logfiles won't confuse anyone anymore
 
  


Reply

Tags
apache, debian, jsp, postgresql, tomcat


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile php with zlib on Debian Lenny (Debian 5.0) mike_phi Debian 1 08-24-2010 11:37 AM
does Debian Lenny/sid support Debian Sarge Binary Installer..? @nthoon Debian 1 06-14-2009 10:47 AM
LXer: How To Upgrade A Debian Etch System (Server & Desktop) To Debian Lenny LXer Syndicated Linux News 0 02-20-2009 04:30 PM
LXer: The Perfect Server - Debian Lenny (Debian 5.0) [ISPConfig 2] LXer Syndicated Linux News 0 02-19-2009 11:00 AM
jsp on debian eduac Linux - Software 2 01-22-2004 06:31 PM


All times are GMT -5. The time now is 07:51 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration