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 not sent to the Tomcat server under the WebApps to run, relatively better compatibility, 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 the new dialog box pops up, depending on the actual operating environment of our computer, here I choose Apache Tomcat v8.0 and click Finish
Then click Browse to select the location where the Tomcat server is installed, the path to the CATALINA_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 under WebApps, but we can integrate the webcontent and build directories into native projects and run them manually
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 Apps with eclipse