Configuring Java/JSP with Postgresql in Redhat Linux
The first thing would be to install JDK for this. Go to this
URL http://java.sun.com/j2se/1.4.2/download.html
This will ask you to agree to their terms and conditions
Choose the Linux self-extracting file in the second table on this page.
The download will be a binary file, log in as root and execute
./j2sdk-1_4_2_02-linux-i586-rpm.bin
and then
rpm -ivf j2sdk-1_4_2_02-linux-i586-rpm
This should install java in the folder /usr/java
Occasionally the binary file may not run, then add execute permissions
chmod 0777 j2sdk-1_4_2_02-linux-i586-rpm.bin
or
chmod +x j2sdk-1_4_2_02-linux-i586-rpm.bin
and then run the two commands.
Then we need to configure java in the classpath.
I normally do this in the /etc/profile file.
This ensures that all users can access java.
Otherwise add these lines to the .bash_profile file
in your home directory.
remember to run this file you have edited, otherwise log off and log on again or restart
the computer.
now type javac in the konsole or xterminal
this should throw a message explaining the syntax. If there is a
message saying that no command found, then there is an error in the configuration or you
have not restarted the computer.
Now we need a JSP server, tomcat is a free server.
Go to http://www.apache.org
and download the zipped file. They are the same for windows and linux.
Unzip the file and put it in a folder. I had put it in /usr/tomcat4.
Now go to the bin folder and type ./startup.sh
You should get a few lines of code mentioning java home,catalina home and a
couple more lines.
Now open a browser and type http://localhost:8080
You should see a welcome page with links.
Ensure that you have a web server on at that time(usually apache)
If you are root type
service httpd status
you should get a message mentioning PIDs and saying that the service is on
If not type service httpd start
Note that the service command works only if you are root , logged in as root
in the main terminal.
Service does not work if you have types su or have logged into the server
as root from another terminal.
Otherwise go to /etc/rc.d/init.d/
and then type httpd -k start(I am a little unsure about this part).
Now for the postgresql part.
Redhat 9.0 ships 3 postgresql rpms by default for versions 7.1, 7.2 and 7.3
type this command rpm -ql postgresql-jdbc*
This will display the 3 rpms (these are already installed, do not reinstall)
Choose the version according to your postgresql database.
Now we need to copy these files into Tomcat's lib folder
/usr/tomcat4/lib or wherever tomcat has been unzipped.
That should be it.
Remember this will only give access to JSP pages to Postgresql.
If you want a .java file to have access to Postgresql they must be put
inside the JSP classes folder, normally the /WEB-INF/classes folder
inside Webapps or any other virtual directory.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.