Then use the same javac HelloWorld.java to compile this document, if there is no import javax.servlet .*
So that should be C: \ Tomcat \ common \ lib inside servlet.jar copy files to the C: \ JDK \ jre \ lib \ ext, again compiled, there will be no problem!
Tomcat then the directory C: \ Tomcat \ webapps \ ROOT inside the file structure as follows:
ROOT \ index.html
ROOT \ welcom.jsp
ROOT \ WEB-INF \ lib \ MyServlet.jar (If your servlet's. Fight a class. Jar file, on the lib below)
ROOT \ WEB-INF \ classes \ HelloWorld.class (HelloWorld.class the above documents generated on the inside)
Then enter http://localhost:8080/servlet/HelloWorld browser, the popular will and therefore Server error: Error 404 - Not Found
How all?
Servlet must use the C: \ Tomcat \ webapps \ ROOT \ WEB-INF directory of the following web.xml file registration with the EP open web.xml file,
On the inside to join
HelloWorld
HelloWorld
HelloWorld
/ Servlet / helloworld
This structure
HelloWorld
HelloWorld
That the designation includes servlet class.
And the following structure
HelloWorld
/ Servlet / HelloWorld
HelloServlet that should be designated where a URL mapping mode.
After revising the web.xml finished, restart Server, and then enter http://localhost:8080/servlet/HelloWorld, then lined a Hello, World! Waiting for you? Congratulate you get the:)
Amat, a tired hands, wrote on it here, it is hoped that role for beginners!
Saturday, August 2, 2008
How kind runtime environment configuration JSP
Abstract: how kind runtime environment configuration JSP
How kind runtime environment configuration JSP
First, download tools:
I suggest that beginners use JDK Editplus +, I think that if we use such as JB, Eclipse, JCreator, although just at the beginning of more convenient, but it does lead to beginners do not know how the door configuration environment variable,
Thus making it difficult to know these, know why they are so the state can be downloaded from the following address:
Editplus (the latest version is v2.11): http://count.skycn.com/softdown.php?id=3641&url=http://sc-http.skycn.net/down/epp211a_cn.exe (as a registration key to find it on their own, many of the Internet)
JDK (the latest version is Java2sdk1_4_2): http://count.skycn.com/softdown.php?id=3116&url=http://sc-http.skycn.net/down/j2sdk-1_4_2-windows-i586.exe ( This is For Windows)
Then JDK is installed, I installed it to the c: \ JDK directory:
CLASSPATH then is the problem:
As the operating system use PATH to search executable programs, the Java runtime environment will be to find Ergodic CLASSPATH category, even HelloWorld such a simple procedure, will traverse JVM
CLASSPATH definition of each path, until you find the corresponding documentation so far.
We believe that the systems in use is not 2 k XP, and then on the Path should be set up as follows:
My computer -> Properties -> High -> environment variables and then the Path environment variable behind Supplementary: C: \ JDK \ bin;. C: \ JDK \ lib
This configuration can be: C: \ JDK \ bin;. C: \ JDK \ lib \ dt.jar; C: \ JDK \ lib \ tools.jar
รข˜… Remember: in the environment variable. Remember not less, it said that the current path, but less if the mistakes, and so will say!
Dt.jar is on the operating environment of class libraries, tools tools.jar is on the Class if there is no configuration: C: \ JDK \ bin, will be a "javac 'is not an internal or external command, it can not run the program or batch file. "Such a mistake.
Then write the procedures below:
The first is (HelloWorld.java), opened Editplus, a new Java files, in keeping with the following input, the word not to leak, and to distinguish between upper and lower case:
Public class HelloWorld (
Public static void main (String [] args) (
System.out.println ( "Hello, World!");
)
)
This then save the file (ctrl + s) to HelloWorld.java, we must remember to distinguish between upper and lower case, is not helloworld.java HelloWorld.java or other Below the running start -> run -> cmd
In the console switch to the directory in the current directory:
Javac HelloWorld.java
Java HelloWorld
You will see the console output Hello, World! (No? I eat a computer:))
Javac compiler is an order it to compile into HelloWorld.class HelloWorld.java
Java is explained orders, the HelloWorld.class explained JVM implementation.
At this time:
1. If there Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
It is in your environment variables that did not add. (Dot)
2. If there Exception in thread "main" java.lang.NoSuchMethodError: main
Or HelloWorld.java: 1: Public class helloworld must be defined in a file called
"HelloWorld.java."
That is, you do not have to distinguish between upper and lower case writing this HelloWorld, or preserved for the time did not keep HelloWorld.java
The name will follow the same public class names
For the problem of environment variables Here, I first say how Below Editplus inside the building and operation of the Tools-> Settings -> configuration user tools
1. Add tools (add applications)
Menu text: Compile Java Program
Procedure: C: \ JDK \ bin \ javac.exe
Parameters: the initial directory file name: document directory
2. Add tools (add applications)
Menu text: Run Java Program
Procedure: C: \ JDK \ bin \ java.exe
Parameters: the file name (without extension)
Initial Catalog: file directory
Tool name can easily add, for example, Debug Java Program
Then in the Tools pull-down menu, you will see Compile Java Program Run Java Program, as well as the two options, since you can use a ctrl + compiler and the operational procedures ctrl +2
Below Servlet discussion on the Run:
Servlet first run, the need for JSP / Servlet container, I suggest that beginners use Tomcat
Tomcat (the latest version 5.0): http://cvs.apache.org/builds/jakarta-tomcat-5/nightly/jakarta-tomcat-5-bin-20030725.zip
Then extract the compressed to:
C: \ Tomcat
Then configuration environment variable:
Add three systems variables:
JAVA_HOME: C: \ JDK
TOMCAT_HOME: C: \ Tomcat
CLASSPATH:% JAVA_HOME% \ lib;% TOMCAT_HOME% \ lib
Tomcat environment variables on the configuration finished, the following test Tomcat whether to run:
In the console to the C: \ Tomcat \ bin directory of this, the startup operation, and then back to the emergence of a window, and even a long jump things, and finally said Server has been running in the browser input http://localhost:8080, a welcome interface , it will be no problem for the Tomcat, and then above, write your first Servlet
Import java.io. *;
Import javax.servlet .*;
Import javax.servlet.http .*;
Public class HelloWorld extends HttpServlet
(
Public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
(
Response.setContentType ( "text / html");
PrintWriter out = response.getWriter ();
Out.println ( " ");
Out.println ( "
How kind runtime environment configuration JSP
First, download tools:
I suggest that beginners use JDK Editplus +, I think that if we use such as JB, Eclipse, JCreator, although just at the beginning of more convenient, but it does lead to beginners do not know how the door configuration environment variable,
Thus making it difficult to know these, know why they are so the state can be downloaded from the following address:
Editplus (the latest version is v2.11): http://count.skycn.com/softdown.php?id=3641&url=http://sc-http.skycn.net/down/epp211a_cn.exe (as a registration key to find it on their own, many of the Internet)
JDK (the latest version is Java2sdk1_4_2): http://count.skycn.com/softdown.php?id=3116&url=http://sc-http.skycn.net/down/j2sdk-1_4_2-windows-i586.exe ( This is For Windows)
Then JDK is installed, I installed it to the c: \ JDK directory:
CLASSPATH then is the problem:
As the operating system use PATH to search executable programs, the Java runtime environment will be to find Ergodic CLASSPATH category, even HelloWorld such a simple procedure, will traverse JVM
CLASSPATH definition of each path, until you find the corresponding documentation so far.
We believe that the systems in use is not 2 k XP, and then on the Path should be set up as follows:
My computer -> Properties -> High -> environment variables and then the Path environment variable behind Supplementary: C: \ JDK \ bin;. C: \ JDK \ lib
This configuration can be: C: \ JDK \ bin;. C: \ JDK \ lib \ dt.jar; C: \ JDK \ lib \ tools.jar
รข˜… Remember: in the environment variable. Remember not less, it said that the current path, but less if the mistakes, and so will say!
Dt.jar is on the operating environment of class libraries, tools tools.jar is on the Class if there is no configuration: C: \ JDK \ bin, will be a "javac 'is not an internal or external command, it can not run the program or batch file. "Such a mistake.
Then write the procedures below:
The first is (HelloWorld.java), opened Editplus, a new Java files, in keeping with the following input, the word not to leak, and to distinguish between upper and lower case:
Public class HelloWorld (
Public static void main (String [] args) (
System.out.println ( "Hello, World!");
)
)
This then save the file (ctrl + s) to HelloWorld.java, we must remember to distinguish between upper and lower case, is not helloworld.java HelloWorld.java or other Below the running start -> run -> cmd
In the console switch to the directory in the current directory:
Javac HelloWorld.java
Java HelloWorld
You will see the console output Hello, World! (No? I eat a computer:))
Javac compiler is an order it to compile into HelloWorld.class HelloWorld.java
Java is explained orders, the HelloWorld.class explained JVM implementation.
At this time:
1. If there Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
It is in your environment variables that did not add. (Dot)
2. If there Exception in thread "main" java.lang.NoSuchMethodError: main
Or HelloWorld.java: 1: Public class helloworld must be defined in a file called
"HelloWorld.java."
That is, you do not have to distinguish between upper and lower case writing this HelloWorld, or preserved for the time did not keep HelloWorld.java
The name will follow the same public class names
For the problem of environment variables Here, I first say how Below Editplus inside the building and operation of the Tools-> Settings -> configuration user tools
1. Add tools (add applications)
Menu text: Compile Java Program
Procedure: C: \ JDK \ bin \ javac.exe
Parameters: the initial directory file name: document directory
2. Add tools (add applications)
Menu text: Run Java Program
Procedure: C: \ JDK \ bin \ java.exe
Parameters: the file name (without extension)
Initial Catalog: file directory
Tool name can easily add, for example, Debug Java Program
Then in the Tools pull-down menu, you will see Compile Java Program Run Java Program, as well as the two options, since you can use a ctrl + compiler and the operational procedures ctrl +2
Below Servlet discussion on the Run:
Servlet first run, the need for JSP / Servlet container, I suggest that beginners use Tomcat
Tomcat (the latest version 5.0): http://cvs.apache.org/builds/jakarta-tomcat-5/nightly/jakarta-tomcat-5-bin-20030725.zip
Then extract the compressed to:
C: \ Tomcat
Then configuration environment variable:
Add three systems variables:
JAVA_HOME: C: \ JDK
TOMCAT_HOME: C: \ Tomcat
CLASSPATH:% JAVA_HOME% \ lib;% TOMCAT_HOME% \ lib
Tomcat environment variables on the configuration finished, the following test Tomcat whether to run:
In the console to the C: \ Tomcat \ bin directory of this, the startup operation, and then back to the emergence of a window, and even a long jump things, and finally said Server has been running in the browser input http://localhost:8080, a welcome interface , it will be no problem for the Tomcat, and then above, write your first Servlet
Import java.io. *;
Import javax.servlet .*;
Import javax.servlet.http .*;
Public class HelloWorld extends HttpServlet
(
Public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
(
Response.setContentType ( "text / html");
PrintWriter out = response.getWriter ();
Out.println ( " ");
Out.println ( "
Set JSP development, runtime environment
Abstract: Setting JSP development and runtime environment
Servlet and JSP 2.1 installation development tools
To learn Servlet and JSP development, first of all, you must be prepared to comply with a Java Servlet 2.1/2.2 and JavaServer Pages1.0/1.1 standardized development environment. Sun provides free JavaServer Web Development Kit (JSWDK) can be downloaded from http://java.sun.com/products/servlet/.
JSWDK installed, you should tell javac, when the document was compiled Where to find Servlet and JSP category. JSWDK Installation Guide of this detailed description, but the main servlet.jar and jsp.jar is to join the CLASSPATH. CLASSPATH instructions Java is a class how to find the document environment variables, if we do not set CLASSPATH, Java standards in the current directory and find the system; If you set up a CLASSPATH, do not forget that includes the current directory (that is, in the CLASSPATH contains. " ").
Furthermore, in order to prevent and other developers to the same Web server installed on a naming conflict Servlet best to pack their own Servlet Add inside. At this time, the packets in the top-level directory structure also joined CLASSPATH will bring a lot of convenience. Please see below specify.
2.2 installation support Servlet Web server
In addition to developing tools, you want to support the installation of a Java Servlet Web server, or in the existing installed on the Web server Servlet package. If you are using the latest Web server or application server, it may already have all the necessary software. Please check the Web server document, or visit http://java.sun.com/products/servlet/industry.html Show support Servlet server software inventory.
Although the final run Servlet is always business-class servers, but when the study began, with a desktop machine can run on the free system development and testing are adequate. Below are some of the most popular products.
Apache Tomcat.
Tomcat Servlet 2.2 and the JSP 1.1 specifications to achieve the official reference. Tomcat can separate small Servlet and JSP test server, but also can be integrated into the Apache Web server. Until early 2000, the Tomcat is the only support Servlet 2.2 and JSP 1.1 specifications of the server, but there have been many other servers that provide support in this respect.
Apache Tomcat and the same is free of charge. However, the rapid, steady, the Apache server installation and configuration with a little trouble, the Tomcat also has the same shortcomings. And other business-class Servlet engine compared to the workload of Tomcat configuration, it must more. For details, please see http://jakarta.apache.org/.
JavaServer Web Development Kit (JSWDK).
JSWDK is Servlet 2.1 and JSP 1.0 achieve the official reference. The Servlet and JSP application deployment to the formal operation of their servers, JSWDK can separate small Servlet, JSP test server. JSWDK is also free, and has good stability, but its installation and configuration also more complex. For details, please see http://java.sun.com/products/servlet/download.html.
Allaire JRun.
JRun is a Servlet and JSP engine, it can be integrated into Netscape Enterprise or FastTrack Server, IIS, Microsoft Personal Web Server, version lower Apache, the WebSite O'eilly or StarNine Web STAR. Supports up to five concurrent connections restricted version is free of charge, does not exist in the commercial version of this restriction, and increased remote management console such functions. For details, please see http://www.allaire.com/products/jrun/.
The New Atlanta ServletExec
ServletExec is a fast Servlet and JSP engine, it can be integrated into the most popular Web server platform includes support for Solaris, Windows, MacOS, HP-UX and Linux. ServletExec free to download and use, but many advanced features and management tools only in the purchase of a license can be used only after. New Atlanta also offers a free Servlet debugger, the debugger can be in many popular Java IDE work. For details, please see http://newatlanta.com/.
Gefion the LiteWebServer (LWS)
LWS is a support Servlet 2.2 and JSP 1.1 free small Web server. Gefion WAICoolRunner there is a free plug-in, using the plug-in for Netscape FastTrack and Enterprise Server 2.2 increase Servlet and JSP 1.1 support. For details, please see http://www.gefionsoftware.com/.
Sun's Java Web Server.
The servers all use Java languages, and is the first to provide Servlet 2.1 and JSP 1.0 specification support of the integrity of the Web server. Although Sun now has shifted to Netscape / I-Planet Server no longer develop Java Web Server, but it is still a popular Servlet and JSP learning platform. To receive a free trial version, please visit http://www.sun.com/software/jwebserver/try/.
Servlet and JSP 2.1 installation development tools
To learn Servlet and JSP development, first of all, you must be prepared to comply with a Java Servlet 2.1/2.2 and JavaServer Pages1.0/1.1 standardized development environment. Sun provides free JavaServer Web Development Kit (JSWDK) can be downloaded from http://java.sun.com/products/servlet/.
JSWDK installed, you should tell javac, when the document was compiled Where to find Servlet and JSP category. JSWDK Installation Guide of this detailed description, but the main servlet.jar and jsp.jar is to join the CLASSPATH. CLASSPATH instructions Java is a class how to find the document environment variables, if we do not set CLASSPATH, Java standards in the current directory and find the system; If you set up a CLASSPATH, do not forget that includes the current directory (that is, in the CLASSPATH contains. " ").
Furthermore, in order to prevent and other developers to the same Web server installed on a naming conflict Servlet best to pack their own Servlet Add inside. At this time, the packets in the top-level directory structure also joined CLASSPATH will bring a lot of convenience. Please see below specify.
2.2 installation support Servlet Web server
In addition to developing tools, you want to support the installation of a Java Servlet Web server, or in the existing installed on the Web server Servlet package. If you are using the latest Web server or application server, it may already have all the necessary software. Please check the Web server document, or visit http://java.sun.com/products/servlet/industry.html Show support Servlet server software inventory.
Although the final run Servlet is always business-class servers, but when the study began, with a desktop machine can run on the free system development and testing are adequate. Below are some of the most popular products.
Apache Tomcat.
Tomcat Servlet 2.2 and the JSP 1.1 specifications to achieve the official reference. Tomcat can separate small Servlet and JSP test server, but also can be integrated into the Apache Web server. Until early 2000, the Tomcat is the only support Servlet 2.2 and JSP 1.1 specifications of the server, but there have been many other servers that provide support in this respect.
Apache Tomcat and the same is free of charge. However, the rapid, steady, the Apache server installation and configuration with a little trouble, the Tomcat also has the same shortcomings. And other business-class Servlet engine compared to the workload of Tomcat configuration, it must more. For details, please see http://jakarta.apache.org/.
JavaServer Web Development Kit (JSWDK).
JSWDK is Servlet 2.1 and JSP 1.0 achieve the official reference. The Servlet and JSP application deployment to the formal operation of their servers, JSWDK can separate small Servlet, JSP test server. JSWDK is also free, and has good stability, but its installation and configuration also more complex. For details, please see http://java.sun.com/products/servlet/download.html.
Allaire JRun.
JRun is a Servlet and JSP engine, it can be integrated into Netscape Enterprise or FastTrack Server, IIS, Microsoft Personal Web Server, version lower Apache, the WebSite O'eilly or StarNine Web STAR. Supports up to five concurrent connections restricted version is free of charge, does not exist in the commercial version of this restriction, and increased remote management console such functions. For details, please see http://www.allaire.com/products/jrun/.
The New Atlanta ServletExec
ServletExec is a fast Servlet and JSP engine, it can be integrated into the most popular Web server platform includes support for Solaris, Windows, MacOS, HP-UX and Linux. ServletExec free to download and use, but many advanced features and management tools only in the purchase of a license can be used only after. New Atlanta also offers a free Servlet debugger, the debugger can be in many popular Java IDE work. For details, please see http://newatlanta.com/.
Gefion the LiteWebServer (LWS)
LWS is a support Servlet 2.2 and JSP 1.1 free small Web server. Gefion WAICoolRunner there is a free plug-in, using the plug-in for Netscape FastTrack and Enterprise Server 2.2 increase Servlet and JSP 1.1 support. For details, please see http://www.gefionsoftware.com/.
Sun's Java Web Server.
The servers all use Java languages, and is the first to provide Servlet 2.1 and JSP 1.0 specification support of the integrity of the Web server. Although Sun now has shifted to Netscape / I-Planet Server no longer develop Java Web Server, but it is still a popular Servlet and JSP learning platform. To receive a free trial version, please visit http://www.sun.com/software/jwebserver/try/.
Subscribe to:
Posts (Atom)