J2sdk and Tomcat5 collocation methods and Precautions

Source: Internet
Author: User
Tags variables variable versions tomcat
I have been using Delphi for many years this good software, recently saw more and more programmers around to learn Java, so, also want to see the ability of Java, is not really as the myth of the said.


Listen to the predecessors speak best from JSP to learn, so this article first talk about the configuration of JSP and JavaBean use.


now, I learn JSP has more than two months, in the JSP configuration also took a lot of detours, now learn to write a note to help people do not go my way. Here I will write a series of learning JSP articles, of course, readers you can not laugh at me, because I write these articles are only suitable for beginners, after all, I am just a beginner.





here please pay attention to:


If your computer uses a proxy server to surf the Internet, please change the following localhost to: 127.0.0.1,


Otherwise you will not be able to display the Web page.








Currently, beginners are advised to start learning JSP with J2SDK + Tomcat 5.0.19. It is also the latest version.


Beginners General and I had the same, do not understand the difference between JDK,J2SDK,J2SE,J2EE, here a brief introduction:


Jdk:java Devolop Kit-Java Development package (run Java most basic Dongdong)


J2SDK: In the 1.4 version formerly known as the JDK, you can understand that J2SDK is the upgrade version of the JDK, so as long as we have a j2sdk can, the JDK is not necessary, OH, installed the upgrade version, but also to install a low-level version?


j2sdk. Several versions correspond to several versions of JAVA2, in which the Java EE need to use the development tool is J2EESDK, but most of the application server (WebLogic JBoss, etc.) are built in J2EESDK.


J2SE:J2SDK is the standard version, in general j2sdk refers to J2SE.


EE: Also known as J2EESDK, used for enterprise-level development.


JRE: Is the Java runtime envionment-Java Runtime Environment, included in the JDK, but for users who do not need to be developed to run only the JRE can be installed alone, so sun provides the JRE download.





can understand the above on the concept is almost, it should not be difficult, if it is not fully understood, it does not matter, after learning the following chapters with me, you look back and forth, it is clear.





j2sdk Download Address: http://java.sun.com/j2se/1.4.2/download.html


tomcat5 Download Address: http://www.apache.org/dist/jakarta/





Installation steps:


1. After installing J2SDK, add the following environment variables in My Computer-> properties-> Advanced-> environment variable-> system variable (assuming your j2sdk is installed in c:\j2sdk1.4.2):


java_home=c:\j2sdk1.4.2;


classpath=.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar; (.;;; Cannot be less, represents the current path)


path=%java_home%\bin; (The system already has a path variable, just add it to the front of the path)


can then write a simple Java program to test whether the J2SDK has been installed successfully:


public class myjava{


public static void Main (String args[]) {


System.out.println ("Try it, pack it?");


}


}


Save the above program as a file named Myjava.java.


Then open the Command Prompt window, the CD to your Myjava.java directory, and then type the following command


Javac Myjava.java


Java Myjava


at this point if you see the results of the installation is successful, error will carefully check your configuration.





2. After installing Tomcat, add the following environment variables in My Computer-> properties-> Advanced-> environment variable-> system variable (assuming your Tomcat is installed in C:\TOMCAT5):


CATALINA_HOME=C:\TOMCAT5;


CATALINA_BASE=C:\TOMCAT5;


then modifies the classpath in the environment variable to append the Servlet-api.jar under Common\lib tomat installation directory to TOMCAT5 (this file is previously named: Servlet.jar) in Classpath. The modified classpath is as follows:





classpath=.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar;%catalina_home%\common\lib\servlet-api.jar; (It is best to copy it to: C:\j2sdk1.4.2\jre\lib\ext directory)


can then start Tomcat, Access http://localhost:8080 in IE, and if you see the Tomcat Welcome page, the installation is successful.





The third step: Build your own JSP app directory


1. To the WebApps directory of Tomcat's installation directory, you can see the directory of Tomcat from Root,examples, etc.


2. Create a new directory under the WebApps directory, named MyApp;


3.myapp Create a new directory Web-inf, note that the directory name is case-sensitive;


4.web-inf to create a new file Web.xml, which reads as follows:


<?xml version= "1.0" encoding= iso-8859-1 "?>"





<! DOCTYPE Web-app


Public "-//sun Microsystems, INC.//DTD Web application 2.3//en"


"HTTP://JAVA.SUN.COM/DTD/WEB-APP_2_3.DTD" >





<web-app>


<display-name>my Web application</display-name>


<description>


A application for test.


</description>


</web-app>








5. Under MyApp, create a new JSP page for the test, the file name is index.jsp, and the file reads as follows:





<html>


<head><title> everyone good </title>


</head>


<body>


<% out.println ("Everyone good, my first JSP program"); %>


</body>


</html>





6. Restart Tomcat


7. Open the browser and enter the http://localhost:8080/myapp/index.jsp.





here, you can start to write JSP program, here to introduce a few write JSP better tools:








DreamWeaver MX


EditPlus


Jbuilderx


If you have deep HTML skills, you can use Notepad, haha.











Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.