JS can knock me tired ah, oh, can't find the whole of the document, on their own wrote a, let me like the rookie door Easy point:). This article only uses Tomcat to write the program, does not do the server environment, therefore does not integrate Apache.
Then open the browser, enter http://localhost:8080, if you can see a sick kitten looking at you, then congratulations, Tomcat also became.
3. Install PostgreSQL
Now that you have downloaded the PostgreSQL installation package, and it is rpm, installation is very convenient: to http://www.postgresql.org to go down of course, there are many mirror, I went to Taiwan's a mirror site under the FOR?AS3 package, You can also look for it, download to the/download directory
#cd?/download
#rpm-IVH?--nodeps?postgresql*.rpm????????? Be sure to add--nodeps, rest assured that the use of installed after no problem
When you are done, you can use the #service?postgresql?start????? To start Pgsql, if you see Starting?postgresql?service:?????????????????? [? OK?] So, Pgsql can also run, of course, you can look at the default settings:
#su?-? Postgres
#psql
Of course, remember to Initdb first.
Now, let's start testing servlet,jsp, and JSP connections PostgreSQL
4.Tomcat Test
First of all, we test the JSP, because this is relatively simple.
#cd?/usr/local/tomcat/webapps
#mkdir????????????????????-p?myapp/web-inf? Note case
#cp? Root/web-inf/web.xml?myapp/web-inf
#vi? myapp/index.jsp
This is not accessible through http://localhost:8080/myapp/index.jsp, and you need to add a context to Tomcat
VI?.. /conf/server.xml
Find and then add the paragraph after it.
Restart Tomcat and enter http://localhost:8080/myapp/index.jsp in the browser
Restart TOMCAT4, open the browser input http://localhost:8080/myapp/Test, should be displayed this?is?a?servlet?test.
If there is an error, 400 error, said not found the file, should be Server.xml did not write the context, if it is 500 error, then the program has a problem:
Please resolve other errors yourself.
5. Connecting to the database
This need PostgreSQL jdbc, we started rpm?-ivh?post*.rpm, already installed, use rpm?-qa?|? Grep?post
Find out the name of the package for this JDBC
Ostgresql-7.4.1-1pgdg
Postgresql-jdbc-7.4.1-1pgdg
Postgresql-libs-7.4.1-1pgdg
Find the path to it.
#rpm?-ql?postgresql-jdbc-7.4.1-1pgdg
Found in/usr/share/pgsql/, the list of files is as follows:
/usr/share/pgsql/pg74.1jdbc1.jar
/usr/share/pgsql/pg74.1jdbc2.jar
/usr/share/pgsql/pg74.1jdbc2ee.jar
/usr/share/pgsql/pg74.1jdbc3.jar
This jdbcx.jar corresponds to the JDBC version respectively, and I made jdbc2.0, so I did
#cp? pg74.1jdbc2.jar?pg74.1jdbc2.jar.bak
#mv? Pg74.1jdbc2.jar?postgresql.jar
Put the Postgresql.jar in the/usr/java/jdk/jre/lib/ext/, or you can add it to the classpath.
Write a simple JSP script to test the connection database
pgsql.jsp
?
?
?
?
?
Your first field content is:?
The contents of your second field are:?
?
?
?
?
?
Save this file under myapp/and then http://localhost:8080/myapp/pgsql.jsp, there should be no problem, I have tested it through.
Congratulations, a simple development environment has been built
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.