Build a Web page with Eclipse (text)

Source: Internet
Author: User
Tags tomcat server

Step 1: Create Dynamic Web project--Web projects.

Open Eclipse, selected in New-->dynamic Web Project on the toolbar


In the Dynamic Web Project window that opens, enter a project name. Select Tomcat, other defaults, and then next.


Display the following Figure window, at which point you can change the context directory name to Webroot, or default to WebContent, complete. This creates a Web project named Dynamic_web_project_01 in the left window of Eclipse, and the Web project is created.


Step 2, create the JSP file on the Web project.

Right-click the name of the Web project you just created, my project name is dynamic_web_project_01,new-->jsp file, and enter the JSP file name. Here I default the filename (it is best to change the file name to index.jsp otherwise, if you want to add a path when you run the Step 4, otherwise you will be wrong.) Then you need the browser to enter the URL http://localhost:8100/dynamic_web_project_01/ newfile.jsp, if you modify the file name of index.jsp after not so much trouble, the following figure I do not modify, in order to facilitate their own file name change over, hey, next default settings, Finish. The following figure shows a chart of the Web project, at which point the. jsp file is created.


Step 3, modify the JSP default code.

In step 2 when we have the default JSP code default, when this default setting, the Web page is not supported in Chinese, need to modify, the code in the "Iso-8859-1" to "GB18030".


For the convenience of reproduction, paste code as follows, I am not a newcomer now can not grasp the picture to copy code, hey.

<%@ page language= "java" contenttype= "text/html; charset=gb18030 "

pageencoding= "GB18030"%>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"

"Http://www.w3.org/TR/html4/loose.dtd" >

<meta http-equiv= "Content-type" content= "text/html; charset=gb18030 ">

<title>dynamic Web project</title>

<body>

<center> JSP creation of a Web project complete ...</center>

</body>

Note: When you create a JSP for dynamic Web project, by default, the system-created JSP file is ISO-8859-1 encoded and does not support Chinese. In order for the files created by Eclipse to support Chinese, you can set the default encoding for the JSP file to GB18030 in the preferences. The method is: Toolbar Select Window-->preference


Find the JSP files under the Web open, as shown in the following figure, select Chinese,national Standard in the Encoding column and confirm that OK is complete.


Step 4, run the Web project.

Right-click the new Dynamic Web Project project name Dynamic_web_project_01,run As-->1.run on Server, and your Web project will open in your default browser. (Here's what you need to say, under the premise that your Web server tomcat is running.) When the sever server bar is closed under the Eclipse window bar, you can window-->show the Tomcat server view-->other-->server-->servers the toolbar. )

Attach: Let your website run in an external browser.

When you run your Web site in eclipse, you can not open it in an internal browser window in Eclipse emulation (this is an internal browser for Eclipse's built-in analog browser, and other real browsers installed on your computer are called external browsers, both inside and outside of Eclipse.) Instead, it runs directly using an external browser. The specific steps are as follows:

Select window-->preferences--> on the toolbar to select General-->web Browser in the left column of the Open Preferences window, and then select the Use external Web Browser option. The system default browser and IE browser are listed below, select one, click OK. When you run a Web site project, your Web page will not be displayed in the Eclipse interface, but instead open a Web page in your installed browser, which is the content of your site.

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.