JSP + JavaBean + Servlet Development Environment Configuration Guide

xiaoxiao2021-03-06  20

JSP JavaBean Servlet Development Environment Configuration Guide Repost: SNOW Date: 2004-11-18 Popularity: 1318 **************************** ******** This post is searching from online, it is the best configuration guide I found to begin with JSP. The original author has not been determined, but thank you here. At the beginning, I traversed Tomcat English document. I still can't find a method of installing the installation configuration of Servlet (I have limited elevated levels), and later I saw this post. It is worth promoting. ******************************************************* J2SDK1.5 download address: http://java.sun .com Tomcat5.5 Download address: http://jakarta.apache.org/site/binindex.cgi J2SDK1.5 installation directory: C: /J2SDK1.5.0 Tomcat5.5 installation directory: C: / Tomcat 1. Configure J2SDK1. 5.0 1.Windows 2000 Server Series Configuring My Computers -> Properties -> Advanced -> Environment Variables Additional Variable Name: Java_Home Variables: C: /J2SDK1.5.0 Additional Variable Name: Path Variable Value:% Java_Home% / BIN ; Add variable name: ClassPath down variable value:.;% Java_home% / lib; or.;% Java_home% / lib / dt.jar;% java_home / lib / Tools.jar * Note: ".;" represents the current directory All references, "% ...%" variable macro replacement. 2. Configure Notepad to edit AutoExec.bat under the Windows 9x series: set java_home = c: /j2sdk1.5.0; set path =% PATH%;% java_home% / bin; set classpath =.;% Java_home% / lib; or.;% java_home% / lib / dt.jar;% java_home% / lib / Tools.jar 3.Windows XP, 2003 Server can be configured 4. Run a. Edit the following with Notepad Code and save it as helloworld.java: public class helloworld {public static void main (string [] args) {system.out.println ("Hello, World!");}} B. Start -> Run -> cmd Switch to the current directory: Javac HelloWorld.java Java HelloWorld You will see the output Hello, World! * Note: Javac is compiled in the console, which compiles helloWorld.class Java to explain the command. JVM explains the HelloWorld.Class to this Java running environment configuration, debugging.

II. Configuring Tomcat5.5 1.Windows 2000 Server Series Configuring My Computer -> Properties -> Advanced -> Environment Variables Additional Variable Name: Tomcat_Home Variables: C: / Tomcat Additional Variable Name: ClassPath Under Variables:% Tomcat_home % / common / lib; 2. Windows 9X series Configure Notepad editing autoexec.bat, add the following statement: set tomcat_home = c: / tomcat; set classpath =% classpath%;% Tomcat_Home% / COMMON / LIB; 3. Windows XP, 2003 Server can all configure the above two methods, you can run in the console to go to the C: / Tomcat / bin this directory, run startup.bat, then there will be a window, even jump a big string, and finally Represents Server Has been running: "Server Startup In ... MS" Opens the IE browser and enters: http: // localhost: 8080 At this point, the welcome interface indicates that Tomcat is OK! Go to the C: / Tomcat / bin in the console, run shutdown.bat, turn off the server. To this Tomcat run environment configuration, debugging is completed. III. Configure JavaBeans 1. Edit the following code with Notepad and save it as circle.java: package abc.def; import java.io. *; public class circle {int RADIUS; public circle () {RADIUS = 1;} public int getRadius () {return radius;} public void setRadius (int newRadius) {radius = newRadius;} public double circleArea () {return Math.PI * radius * radius;} public double circleLength () {return 2.0 * Math.PI * Radius;}} 2. Save Circle.java in a C: / Tomcat / Common / Classes / ABC / DEF directory.

3. Start -> Run -> CMD Switch to the current directory in the console: javac circle.java or directly enter javac c: /tomcat/common/Classes/abc/def/circle.java 4. Edit the following code with Notepad, And saved as usebeans.jsp: <% @ page contentty = "text / html; charset = GB2312"%> <% @ page import = "abc.def.circle"%> <% girl.setius (100);%>

circle The radius is: <% = girl.getius ()%>

The circumference of the circle is: <% = girl.circLength ()%>

The area is: <% = girl.circlearea ()%> 5. Save UseBeans.jsp in the C: / Tomcat / WebApps / root directory. 6. After launching the server, open the IE browser and enter: http:// localhost: 8080 / usebeans.jsp, indicating that the JavaBeans is successful! "The radius of the circle is: 100 rounds of circumference: 628.3185307179587 The area is: 31415.926535897932" To this JavaBeans run environment configuration, debugging is completed.

IV .Servlet Configuration 1.Windows 2000 Server Series Configuring My Computer -> Properties -> Advanced -> Environment Variables Additional Variable Name: ClassPath Under Variable Value:% Tomcat_Home% / Common / lib / servlet-api.jar; 2. Under the Windows 9x series, configure notepad editing autoexec.bat, add the following statement: set classpath =% classpath%;% Tomcat_Home% / common / lib / servlet-api.jar; 3.Windows XP, 2003 Server configure above two Method can be 4. Run a. Edit the following code with Notepad and save it as hello.java: import java.io. *; import javax.servlet. *; Import javax.servlet.http. *; Public class hello extends httpservlet {public void init (ServletConfig config) throws ServletException {super.init (config);} public void service (HttpServletRequest request, HttpServletResponse response) throws IOException {PrintWriter out = response.getWriter (); response.setContentType ( "text / html; Charset = GB2312 "); Out.Println (" "); Out.println (" Hello! "); Out.println (" ");}} b. Save Hello.java in a C: / Tomcat / Common / Classes directory.

c. Start -> Run -> CMD Switch to the current directory in the console: Javac Hello.java or directly enter javac c: /tomcat/common/classes/hello.java d. Register servlet to open C: / Tomcat / WebApps / root / web-inf / web.xml at - Welcome to Tomcat Welcome to Tomcat ->. ->. ->. -> - Additional two sets of data: hello Hello < / servlet> Hello / servlet / hello * Note: . .. Id for servlets in Servlet is servlet-class class name ... Mirror path is also virtual path C: / tomcat / common / classes for class sharing directory, can also be: c: / tomcat / webapps / your application directory /Web-inf/web.xml Register, but must be added to the C: / Tomcat / WebApps / under the application of servlets, such as: http: // localhost: 8080 / Your application directory / servlet / hello suggests your own application for the servlet class to be placed C: / Tomcat / WebApps / Your Application Directory / Web-INF / CLASSES; in the web.xml registration servlet classpath is also "/ hello". e. After restarting the server, open the IE browser and enter: http:// localhost: 8080 / servlet / hello display: "Hello!", configure success! To this servlet run environment configuration, debugging is completed. The above is the J2SDK1.5.0 Tomcat 5.5 (04.07.21) Configure environment steps. Since the Tomcat version is updated very fast, the configuration of each version is slightly different.

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

New Post(0)