Introduction to MyEclipse Development and debugging Web application instance

Source: Internet
Author: User
Tags prepare tomcat tomcat server

It is a disadvantage of China's software development industry to overemphasize the ability of development tools and to emphasize the ability of developers to master tools, while ignoring the software engineering management process. Standard is an ideal state, in the implementation of commercial applications have to lower the arrogant head.

The urgent task is to do a good job of OO basic ideological education, library use ideological education, coding standard education and software engineering management basic ideological education.
While GP, Meta programming have their unique technical features and advantages, they do not apply to all project development.

The Chinese software industry will only stagnate if the tool theory and the blind worship of programming technology are not broken.

Author: Junsan Jin

Date: 2006-3-11

Version: 1.0

Mailbox: junnef21@sohu.com

Blog:http://blog.csdn.net/junnef

Website: http://www.inspiresky.com (/bbs)
Software Alliance Group: 17377604

Disclaimer: I reserve all the rights of this article.

It used to be developed using Eclipse plus some free plug-ins, and recently you need to use the JSF framework for project development, searching the web for half a day, and currently in addition to Jbulider and Sun Netbean, What else is that idea? development tools are naturally integrated outside the JSF framework (I'm not exclusive of these development tools, but I used to use them occasionally, but I like Eclipse and I'm used to not wanting to change the development tools, so I'm looking for Eclipse's plug-in package), The free JSF development plug-in for Eclipse began to be found, and later found a WTP JSF plug-in that could be integrated into Eclipse's WTP development plug-in, but a M1 version without a version number, so just wait until it stabilizes. Finally decided to try to use the MyEclipse Development Toolkit, previously on the myeclipse a bit inexplicable rejection, may be because it charges for the sake of it. But put up a trial, feel myeclipse really use up very handy, here on the use of MyEclipse to make a simple introduction.

Use a simple Web application to describe a Web server configuration that uses MyEclipse to apply the deployment and debugging processes.

First, prepare development tools

With Eclipse 3.1.2 and MyEclipse4.1.1, Java is usually used to develop network applications, and so is the Web server, which uses Tomcat version 5.5.15. Of course, if you do not J2SDK then all the programs can not compile the operation, so, you also go to prepare a bar, where the use of J2SDK 1.5.0_06-b05, as long as it is JDK1.5.0 above, it does not matter, we can use all the features.

Download Address:

Http://www.inspiresky.com/bbs/dispbbs.asp?boardID=13&ID=6356&page=1

Http://www.inspiresky.com/bbs/dispbbs.asp?boardID=13&ID=3889&page=1

Http://java.sun.com

http://www.eclipse.org

http://www.apache.org

Http://www.myeclipseide.com/ContentExpress-display-ceid-10.html

There is a MyEclipse registration code, which provides only for personal study and research use, the company users please buy their own serial number.

Second, the installation and registration of software

First to install the JDK, I use the default installation, the directory does not change all, C:/Program Files/java, there are two folders below, one is the JDK, one is the JRE. To set the classpath and so on, please go to the Internet to find relevant information, that many articles said.

Tomcat installation, we use the EXE version of the installation files, in addition to the selection of directories, the other defaults are good, here to install to d:/tomcat5.5, pay attention to the middle of the space removed, because sometimes the space will be very troublesome.

Eclipse is easy to install, just unpack, and then place the unpacked file Eclipse folder in the appropriate installation directory, such as D:/eclipse. Find the Eclipse.exe file in the installation directory, start Eclipse, set the JDK and work path to see the Eclipse's Welcome page. We don't use eclipse here, so turn it off.

MyEclipse is an EXE installation file, there is the Installation Wizard, double-click the installation directly, select the Eclipse installation directory D:/eclipse and its own installation directory, where the use of d:/myeclipse/eclipse, and then all the way next.

We can find the MyEclipse program group in the program group, click Open, if you do not have the default work path, select a work path, you will see the integration myeclipse after the typical eclipse interface.

Finally, you need to enter the MyEclipse registration code, open the menu window->preferences, open the Myeclipse->subscription item in the menu tree of the dialog box, click Enter Subscription ... button, and then enter a registered username and password.

OK, all the required software is installed here, so let's create a simple project to illustrate the application of MyEclipse.


Third, the creation of Web engineering

Because here only explains the basic operation and the setting of MyEclipse, so, do not do very complicated project, completely can analogy.

Open the MyEclipse development interface, file->new->projects ..., open the New Project dialog box, select Myeclipse->j2ee Projects->web Project, click the Next button, on the Web Project details of the projects name in the WebTest, other defaults, note that the context root URL is/webtest, otherwise, you will be in IE to enter the appropriate name to use. Note that the bottom of this is whether to join the tag library support, we choose JSTL1.1. Then, click the Finish button to complete the project creation.


We look at our new projects, the classes that are needed have been automatically loaded in, and a Java EE class environment variable, which is the convenience of using MyEclipse.

New Hello Class

Select the SRC folder under the project WebTest (note that under Package Explorer, if this is not found, go to the Eclipse Usage guide, window->show view->package Explorer), Right-click menu New->package, create a new package Com.inspiresky.bean. Select New Package, right-click menu New->class,name Enter Hello, remove public static void main option, all other defaults, click Finish button to complete class creation.


Edit the code for the class as follows:

Package Com.myqsd.bean;

public class Hello {
Private String message = "Hello World";

Public String GetMessage () {
return message;
}

public void Setmessage (String message) {
this.message = message;
}

}

Notice how the bean properties are manipulated here, you can define the attributes first, then in the edit window, right-click the menu Source->generate getters and Setters, and then in the dialog box, select the property that you want to generate the get and set methods to determine.

V. Create a JSP page


In the WebTest project, select the Webroot folder, right-click menu New->jsp,file name to index.jsp, other defaults, click the Finish button to create.

Edit the contents of the JSP file as follows:


<%@ page language= "java" import= "java.util.*" pageencoding= "Iso-8859-1"%>
<%
String path = Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";
%>
<jsp:usebean id= "Hello" class= "Com.myqsd.bean.Hello" scope= "page"/>

<jsp:setproperty name= "Hello" property= "message" value= "Hello world!"/>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
       <base href= "<%=basePath%>"
   
    <title>my JSP ' index.jsp ' starting Page</title>
   
 <meta http-equiv= ' pragma ' content= ' No-cache ""
 <meta http-equiv= "Cache-control" content= "No-cache"
 <meta http-equiv= " Expires "content=" 0 ">   
 <meta http-equiv=" keywords "content=" keyword1,keyword2, Keyword3 ""
 <meta http-equiv= "description" content= "This are my page"
 <!--
  <link rel= "stylesheet" type= "Text/css" href= "Styles.css"
 -->

<jsp:getproperty name= "Hello" property= "message"/><br>
<body>
This is the My JSP page. <br>
</body>

Notice the code that the Red section adds for us. Well, our code has been written.

VI. Configuring Tomcat Servers

Eclipse menu, Window->preference ..., open the Preference dialog box and locate the Myeclipse->application Servers->tomcat 5 in the menu tree. Select Tomcat 5, in the dialog box, select the Enable radio button, and then click the Browse button in the Tomcat home directory input box to choose Tomcat's installation root, which is d:/tomcat5.5, and the other boxes are automatically populated. Click the Apply button.

Select the JDK in Tomcat 5, where you should pay special attention that the default is the runtime environment of the JRE, which is set to JDK, otherwise the myeclipse will not be able to subordinate the Web application properly and will not run the Tomcat server properly.

We click the Add button, write jdk1.5.0_06 in JRE name, and then select the JDK root in the Browse selection box, which is C:/Program files/java/jdk1.5.0_06, the rest of the default, click OK button. Selecting the one we just created in the Tomcat JDK name is jdk1.5.0_06. Click on the Apply button, every time you click, sometimes eclipse problems, you do not click this run to another configuration page will lose the above configuration.


We made sure that debug mode was selected in the launch of Tomcat 5.

And paths is a number of classpath settings, the first is to load the class path in advance, some packets start the server to initialize the Web application to use, this is the second is the runtime to use, and the third is not packaged classes, here we will ignore.

Now you can click the OK button on the preference dialog to complete the configuration of Tomcat.

Vii. Subordinate Web applications

Here's the simple point, we select the root of the WebTest project, right-click menu Myeclipse->add and Remove Projects deployments ..., make sure Projects is webtest in the Open dialog box. Click the Add button, in the pop-up dialog box in the server select Tomcat 5, the following two single options, exploaded archive and packaged archive respectively is the directory way subordinates and package way subordinates, this is done by the MyEclipse, We use the directory to deploy the way, do not have to fight the war package, the others regardless of it. Click the finished button to return to the previous page.

The server specifies that the application is deployed below. Select the Tomcat 5 item in the dialog server list, at which point the grayed out button becomes available, where the remove and redeploy are removed from the deployment and redeployment, we click the Redeploy button, and later we modify the project or click this button to redeploy. Here we can click on it.


OK, the program has been deployed, the following to run debugging.

Eight, run the debugging program

In the Eclipse's Graphics menu bar (the button on the left is the redeployment button, the right side is the browser), click the Drop-down button, select Tomcat 5, then click the Start menu to start Tomcat.

The Consol window prompts Tomcat to start successfully, so we can run our program. Open an IE browser window, enter http://localhost:8080/WebTest/, we can see the following information:


Hello world!
This is the My JSP page.

Indicates that the operation was successful.

The following is about debugging, hehe, this time and normal debugging like, plus breakpoints. JSP files and class files can be debugged as one step.

Open the Hello.java edit box, in the return message, and a breakpoint on the line, we refresh the IE window, the Eclipse window will appear, stop at the point where the breakpoint. Press F8 to finish and remove this breakpoint.

We open the index.jsp file's edit box, <jsp:getproperty name= "Hello" .../> a line to hit the breakpoint, refresh the IE window. Then go back to the Eclipse editing window and the cursor has stopped at the breakpoint line.

Other debugging is needless to say, as long as the eclipse will know, look at the property status values and so on, and normal debugging is the same.

Okay, here we've covered the basics of how to use MyEclipse, and I'll continue to explain how to use myeclipse to develop JSF, Spring, Hibernate, and struts projects, please pay attention to my blogs and forums

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.