1.
First, write the JavaBean program. Assume that the class name is num. numberguess. The file name is num. java.
2.
Then write the JSP code. Assume that the source file is named index. jsp.
3.
In the tomcat installation directory, create a new directory with a casual name. Assume It is MyApp.
4.
Create two directories in MyApp: WEB-INF and meta-INF. Copy index. jsp to the directory.
5.
Create a web. xml file in the WEB-INF. The content is as follows:
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <web-app version = "2.5" xmlns = "http://java.sun.com/xml/ns/javaee" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <br/> <session-config> <br/> <session-Timeout> <br/> 30 <br/> </session-Timeout> <br/> </session-config> <br/> <welcome-file-List> <br/> <welcome-File> index. JSP </welcome-File> <br/> </welcome-file-List> <br/> </Web-app>
6.
Copy num. Java to WEB-INF/classes/num. Java
7.
Create context. XML in META-INF with the following content:
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <context antijarlocking = "true" Path = "/num"/>
Start Tomcat. Open your browser and enter http: // localhost: 8080/MyApp/num/index. jsp in the address bar. You can access the application you just released.