Developing Java Web pages with eclipse

Source: Internet
Author: User
Tags java web tomcat server virtual environment apache tomcat

I said before. Manually configure an application, manual configuration can be more in-depth understanding of the distribution of Web applications, but the general editor does not have syntax errors, so it is not easy to develop the wrong search, inefficient, so after understanding the structure of the Web project, we use Eclipse development, Can make it more efficient

Development can be done using eclipse for Java EE or myeclipse, the project directory is roughly the same, just running differently, Eclipse is configuring the virtual environment to execute the application, MyEclipse run when the project is published to the Tomcat server under the WebApps to run, both developed the same, the following using Eclipse for Java Web application development steps

After you start eclipse, click "File", "new", "Dynamic Web Project" in the menu bar to create a new Web site item

  

Then the name of the item in the popup dialog box is filled in Jsp1, and by default the option value in Target runtime is none, we need to select the Tomcat runtime and click the New Runtime button

  

Then pop up the new dialog, the environment according to the actual operating environment of our computer selection, here I choose Apache Tomcat v7.0 or 8.0 and then click Finish

  

Then click Browse to select the location where the Tomcat server is installed, the path to the JAVA_HOME environment variable, and click Finish

  

Now, a Web project is set up, and the directory structure is broadly like this:

  

Where WebContent is our JSP source file directory, below the Web-inf and Meta-inf two directories, and our previous Web application directory consistent

So now we create a new source file, right-click on WebContent, select "New", "Jsp file"

  

In the pop-up menu, fill in the JSP file name in file name, fill in the Index.jsp, and click Finish

  

OK, now that one of our simple Web applications is complete, you can click the Green Run button above to run the app, or you can right-click on the pop-up menu in the Code Editor and select "Run on Server" running the program

  

This time the dialog box pops up and we just click Finish to start the run

  

The server starts up, then opens a built-in window in Eclipse and then displays the corresponding page

Note that at this point in our Eclipse working directory, there will be a servers directory under the project's sibling directory, which is the directory generated by the eclipse configuration runtime and can be seen in the project manager

  

Note that this directory does not delete, otherwise the program can not run, but also need to rebuild, Server.xml, Web. XML, context.xml and other configuration files are present in this directory

Currently the server is in the running state, we open the browser input http://localhost:8080/Jsp1/index.jsp can also be correctly accessed to

The list of servers and projects that we configured can be seen in the Servers tab of the Eclipse window below.

  

We can easily right click to select Start, stop, restart and other operations, and then through the browser to debug the project

The project directory for Eclipse cannot be copied directly to WebApps, but we can integrate the webcontent and build directories into native projects and run them manually; the more common way is to export the project in the war format to the Tomcat application directory. The runtime server will unpack automatically

  

Finally add that if we configure too many servers, or mistakenly delete causes the server to fail, then how can we remove the original configuration option to start the configuration again?

First, right-click the servers directory in the project manager, select Delete and tick delete file delete.

Then the following server stops after we are also right-click to tick the delete configuration and remove this server option

Finally click "Window", "Preferences" in the menu bar, which means the preference

  

Then, in the Popup dialog box, select "Server", "Runtime environments" on the left, then select the server on the right to remove the click "Remove" button, then click OK button to complete

  

This time has been cleaned up, we can start to configure the Java Web Development environment again

Developing Java Web pages with eclipse

Related Article

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.