Transfer Eclipse as a development environment of Jakarta Tomcat

xiaoxiao2021-03-05  23

Use Eclipse as a development environment of Jakarta Tomcat: chinaitlab collection 2004-8-17 11:10:00

Downloading Components When setting up Eclipse, you need to use several components when you work with Tomcat. These components are shown in Table 1.

Table 1. Components and version numbers used herein

Download the components you want. Site where you can download these files can be downloaded in this article, these sites are available in this article. Eclipse IDE: Eclipse IDE is used as a development environment of JSP pages and Java files. Eclipse is a very easy to use IDE environment, which has a lot of features that can help programmers quickly write and debug the Java program. After adding the Tomcat plugin, this IDE is a very good tool to manage the entire web project (including HTML and JSP pages, icons, and servlets). Sun SDK: Tomcat Eclipse plugin For a sdk necessary to work properly. This SDK may not be SUN SDK, but must be an SDK, (cannot be a JRE, because this is not working properly). In order to make Tomcat work with Eclipse, there must be a Java compiler in the SDK. Tomcat: Drive JSP page needs to use Tomcat. The Tomcat engine is a very good servlet engine that is free to download and very easy to install. Sysdeo's Eclipse Tomcat startup plug-in: This is one of the many Eclipse plugins for Jakarta Tomcat. This is a very good plugin, which saves me a lot of time, can integrate web projects and Java code well, I usually use Eclipse to write these code. After installing all components downloads the required components, the next step is to extract each file. Unpack these files and put all of them in the same directory so that all files after all decompression can be found. Copy the Tomcat plugin to the Eclipse / plugins directory After all of the files are completely detached, copy the Tomcat plug-in directory to the Plugins subdirectory in the Eclipse directory. I solve the directory name from sysdeo's ZIP file is com.sysdeo.eclipse.tomcat_2.2.1, copy this entire directory to the Eclipse / Plugins directory. Install SDK Next, install the SDK just downloaded. Tomcat's Eclipse plugin requires JRE set in the Eclipse workspace, is a real SDK with a Java compiler. This is a requirement using the SYSDEO Tomcat plugin. After installing the SDK, you can start the Eclipse workbench. Eclipse default JRE must be from a SDK Tomcat plugin to the default JRE of Eclipse settings, otherwise the Tomcat plugin does not work properly. Configuring this SDK's JRE Set to Eclipse default JRE before starting Eclipse, you need to configure some options in the workbench's preferences page. Select Window> Preferences to open the Preferences dialog, as shown in Figure 1.

Figure 1. Eclipse's Preferences dialog

Select the Java option in the tree view on the left. Expand the Java element and select Installed JRE, as shown in Figure 2.

Figure 2. The Preference setting of JRE Click "Add" and switch to the JRE directory installed in the installation phase configured above, as shown in Figure 3. Click OK.

Figure 3. Add a JRE to the Preference settings of Eclipse

Check the box on the edge of JRE added when you have just installed SDK, as shown in Figure 4. This is set to the default JRE used by Eclipse. Only this step is set correctly, the Tomcat plugin can work. The Tomcat plugin requires the default JRE selected in these settings to be an SDK.

Figure 4. Setting the default JRE for Eclipse and Tomcat

Set the trect's Home variable in Tomcat's preferences next to set the preferences of the Tomcat plugin. Now the Preferences dialog is still open, select "Tomcat" in the menu on the left, as shown in Figure 5.

Figure 5. Set the preferences of the Tomcat plugin

Select Tomcat from the radio button above. I use the Tomcat version number of 5.0.16, so select the last radio button "Version 5.x". The Tomcat Home variable must then be set. Click the "Browse" button on the "Tomcat Home" dialog box to browse the root directory of Tomcat that has just decompressed, then click the "OK" button. The configuration file will be automatically selected and add the appropriate content in the dialog. If you want to select a different configuration file for Tomcat, you can now browse these files. Otherwise the default value is used normally. Now we have implemented the minimum requirements for starting Tomcat using the Eclipse and Sysdeo Tomcat Launcher plugins. Browse to the other parameter settings for Tomcat in the following Eclipse's Preference dialog, note that there are many other options in Tomcat's parameter settings. For example, you can add a parameter to the JVM used by the Tomcat server. From the workspace, select the Java project to the Tomcat's classpath, and some settings allow Tomcat management applications to test Tomcat and Eclipse to create a new Tomcat project to Tomcat Integrate with Eclipse, you can start from creating a new project. Select File> New> Project and check the wizard content for the new project. There is a new item "Tomcat Project" in the Java section of this project wizard (see Figure 6). Select this option and click Next.

Figure 6. Creating a new Tomcat project

Take a name for this new Tomcat project. For example, "TomcatProject", as shown in Figure 7. Click Next.

Figure 7. Set the name of the Tomcat project

Now we have seen a named name that can be specified for the web project, and you can specify a subdirectory as the root directory of the web application. Now we reserve the default value of it (see Figure 8). Click Finish.

Figure 8. Set the root directory of the Tomcat web application

A project with a WAR structure is now created in the workspace, as shown in Figure 9.

Figure 9. Created Tomcat project

The simplest method for creating a JSP file for testing the test installation process is to create a new file in the root folder of the WAR project. Create a new file first, here is called "INDEX.JSP". To implement this feature, select your own project in the workspace, then click on the right mouse button. Select New> File, name it "index.jsp", as shown in Figure 10, then click Finish. Figure 10. Creating an index.jsp file test configuration

Add the contents in Listing 1 to the Index.jsp file and save this file. Listing 1. INDEX.JSP file sample <% java.util.date d = new java.util.date ();%> todays date is <% = d.Getdate ()%> and this JSP Page Wrap! Start Tomcat is now arriving now using the sysdeo plugin. To start the Tomcat server, simply click on the START Tomcat button in the toolbar, as shown in Figure 11. You can also select the Tomcat menu in the main menu, then select "Start Tomcat".

Figure 11. Start Tomcat Server with Sysdeo Plugin

The Tomcat server will now start, and the text when the startup is displayed in the Console view of the Eclipse table, as shown in Figure 12. Check the launch log and note if there is an error.

Figure 12. Startup information of Tomcat displayed in the Console view of Eclipse

Start your browser and view the index.jsp file When the server is already started, start a web browser. Go to URL http: // localhost: 8080 / TomcatProject. At this point, you will be loaded, you should see a message similar to the following: TodayS Date IS 30 and this JSP page workd! (I have a date on my screen is 30, because today is No. 30.) End language You should have set up Eclipse correctly and configure it to work with Jakarta Tomcat. Now you can quickly develop and integrate JSP and Java code, this excellent program can improve our productivity. Use Eclipse to write Java code and integrate it with Jakarta Tomcat, which makes JSP development more interesting and easier.

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

New Post(0)