Develop servlet using Eclipse3.0

xiaoxiao2021-03-06  50

Use Eclipse3.0 LOMBOZ3.0 JBOSS

3.2.3

Develop servlet

First, please see Using Eclipse3.0 Lomboz3.0 Jboss

3.2.3

Develop EJB (1)

It is exactly the same.

Second, develop a servlet selection menu file-new-other, pop up the following dialog:

Figure 1 Select the Lomboz J2EE Project in Java-Lomboz J2EE Wizards, then click Next:

Figure 2 Enter a project name J2EEPROJECT in Project Name, then click the Next button to pop up Figure 3 dialog.

Figure 3 Click the Add External Jars button in Figure 7Librarles tab, add c: /sun/appser/lib/j2ee.jar, then click Next button

Figure 4 Select the Web Modules tab in the dialog box in Figure 4, then click the Add button to add a MyWeb's Web Module, then select Targeted Servers.

Figure 5

Select the JBoss 3.2.x server, click the Add button, and finally click the Finish button. At this time, Package Explorer looks like Figure 6.

Figure 6

At the project name J2Eeproject, click the right mouse button. Select New in the pop-up menu, select Other, and pop up Figure 7 dialog.

Figure 7

Select Lomboz Servlet Wizard, click Next button, pop up Figure 8 dialog,

Figure 8

According to Figure 8, after entering the parameters, click the Next button.

Figure 9

In the dialog box shown in Figure 9, click the Browse button to select the previously established Web Module: MyWeb, then enter the servlet name and mapping URL, the slash in the mapping URL is necessary, the intermediate Display Name and Description may not lose, finally Click the Finish button.

Find the code in the generated file TestServlet.java:

Protected Void Doget (httpservletRequest Request,

HttpservletResponse response) throws servletexception, ioException {

// Todo Method Stub generated by Lomboz

}

Replace with:

Protected Void Doget (httpservletRequest Request,

HttpservletResponse response) throws servletexception, ioException {

// Set the document type first

Response.setContentType ("text / html; charSet = GB2312");

// Get output flow

PrintWriter out = response.getwriter ();

// Writing page

OUT.PRINTLN ("");

OUT.PRINTLN ("");

Out.println ("HelloWorld");

OUT.PRINTLN ("");

}

Don't forget import java.io. *;

Then, then find the MYWEB folder in Package Explorer, click the right button, select Lomboz J2EE in the pop-up menu, then select Deploy Module, if there is no exception, MyWeb is deployed to D: / jboss-

3.2.3

/ server / default / deploy directory.

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

New Post(0)