Linux platform JSP environment built (Tomcat4 + JDK + PostgreSQL7.4)

xiaoxiao2021-03-06  124

It can be tired, huh, huh, I can't find the overall document online, let myself, let the rookie door, easy to get into the door :) Please indicate the author and the source. This article only uses Tomcat write programs, do not do a Server environment, so you don't integrate Apache. Chinaunix double eyelids: redhat AS3 JDK installation path: / usr / java / jdk Tomcat installation path: / usr / local / Tomcat / total public Divided into the following steps: First, install the configuration JDK II, install the configuration Tomcat three, install the postgreSQL four, Tomcat test 5, the software required to connect the database: J2SDK-1_4_2-Linux-I586-rpm.bin jakarta-Tomcat-4.1 .30.4.1-1pgdg.i386.rpm PostgreSQL-JDBC-7.4.1-1pgdg.i386.rpm PostgreSQL-Server-7.4.1-1pgdg.i386.rpm PostgreSQL-LIBS-7.4.1 -1pgdg.i386.rpm All of these software All in / download a backup #MKDIR / DOWNLOAD 1 installation JDK Download Address: http://java.sun.com/j2se/1.4.2/download.html Download the RPM package In fact, it is a .bin file #CHMOD U X J2SDK-1_4_2-Linux-i586-rpm.bin #. / J2sdk-1_4_2-linux-i586-rpm.bin # rpm -ivh j2sdk-1_4_2-linux-i586-rpm # CD / USR / JAVA / #LN -S J2SDK1.4.2 / JDK / Setting Environment Variable: Don't write / etc / profile here. It can cause each user to start using JDK. Because Tomcat is used to write to Tomcat's Home directory. #Vi /Home/tomcat/.bashrc (can also be .bash_profile) Export java_home = / usr / java / jdk export path = $ PATH: $ java_home / bin extra ClassPath = $ java_home / lib su to tomcat users, see if you can use # sa - Tomcat $ JAVAC $ JAVA? If there is, then the JDK is configured successfully. Re-SU to root 2 Configuring Tomcat Tomcat I am started by Tomcat, please pay attention :) Because I downloaded a binary version, I don't need to compile again.

#cp /download/jakarta-tomcat-4.1.30.tar.gz / usr / local #TAR ZXVF JAKARTA-TOMCAT-4.1.30.TAR.GZ #RM -F JAKARTA-TOMCAT-4.1.30.TAR.GZ # CD JAKARTA-TOMCAT-4.1.30 Add Environment Variable: #vi /Home/tomcat/.bashrc Export Catalina_Home = / usr / local / tomcat export catalina_base = / usr / local / tomat can test whether Tomcat can start normally: #bin /Startup.sh you will see these state: use catalina_base: / usr / local / tomcat using catalina_home: / usr / local / tomcat using catalina_tmpdir: / usr / local / Tomcat / Temp USING JAVA_HOME: / USR / JAVA / JDK Then open the browser, enter http: // localhost: 8080, if you can see a metamorphosis kitte looks at you, then congratulations, Tomcat also became 3 installation PostgreSQL Since you have downloaded PostgreSQL installation package, And rpm, it is very convenient to install :) to http://www.postgresql.org to see, there are a lot of mirror, I went to a Mirror site under Taiwan for AS3 package, you also go to find Let's download to / download # rpm -ivh --Nodeps postgreSQL * .rpm must add --Nodeps, rest assured, after installing without problems, you can use #service postgreSQL Start to start PGSQL, if you see Starting PostgreSQL Service: [OK] So, PGSQL can also run, of course, you can take a look at the default setting # sa - postgres #psql of course, remember to firstddb. Now, we start testing servlet, JSP And JSP connection PostgreSQL 4 first, let's test JSP first because this is relatively simple. #CD / usr / local / Tomcat / WebAP PS #mkdir -p myApp / web-infographic #CP root / web-inf / web.xml myapp / web-inf #vi myapp / index.jsp <% = new java.util. Date ()%> This cannot be accessed by http: // localhost: 8080 / myapp / index.jsp, you also need to add a context vi ../conf/server.xml to Tomcat to restart Tomcat, enter http: // localhost: 8080 / myapp / index.jsp If normal, then Congratulations, this is successful, and the test servlet first writes a simplest servlet.

package test; import java.io. *; import javax.servlet *;. import javax.servlet.http *;. public class Test extends HttpServlet {protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {PrintWriter out = Response.getwriter (); out.println ("

this is a servlet test. ");}} The above file is TEST. Java, then compile with Javac, put the resulting test.class file COPY to / usr / local / tomcat / webapps / myapp / web-inf / class / test / modify myApp / web-inf / web.xml, probably Is this like this a application for test. test test.test test / test Restart Tomcat4, open the browser to enter http: // localhost: 8080 / myApp / test, should be displayed His is a servlet test. If there is an error, the 404 error, indicates that the file is not found, should be not written in server.xml, if it is a 500 error, then the program has a problem :) Please solve it yourself.

转载请注明原文地址:https://www.9cbs.com/read-125914.html

New Post(0)