Learning jsp from scratch (1) Using myeclipse and tomcat to run a simple. JSP program

Source: Internet
Author: User
Document directory
  • 2.4.1 open myeclipse
  • 2.4.2 configure Tomcat path

1 JSP function sp can put Java code and HTML code in one file, which is a good way to develop dynamic websites. 2 install and configure myeclipse, JDK, and tomcat

Myeclipse allows you to conveniently manage web projects and easily integrate Tomcat for JSP debugging. As an extension of Eclipse, myeclipse can implement various functions of Eclipse.

2.1 Download and install a myeclipse

Most of the cracked versions of myeclipse require certain operations to complete the cracking. I am using myeclipse8.0 (this version is old and jdk1.4 and tomcat6.x are supported by default)

For: http://www.cr173.com/soft/11546.html

Follow the instructions on the download page.

2.2 download and install a JDK

JDK can be downloaded on the official website, address: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Environment variables need to be configured after download, see http://blog.csdn.net/shirenfeigui/article/details/7052458

2.3 download and install a tomcat

Tomcat can be used as a JSP server. If you use Tomcat as a JSP server, you need to write the URL correspondence in the corresponding file. This article is skipped due to complexity.

2.4 configure Tomcat 2.4.1 In myeclipse to open myeclipse

When it is opened, you will be asked to specify a workspace. projects created later will be stored in the current workspace directory by default.

2.4.2 configure Tomcat path

In the menu bar-window-preferences, click the pop-up box and select myeclipse-servers-Tomcat 6.x.

(The location varies slightly depending on the version of myeclipse. If not, search for it. If the tomcat version is later than 6, you can also select 6.x)

Then specify the Tomcat path. Click OK after setting.

3. Create a web project and its deployment in Tomcat 3.1 create a web project

File-New-web project

Enter the project name. I entered JSP here. Click Finish.

After that, some default directories are generated in the workspace bar.

Src directory: stores Java source files

Webroot directory: top-level directory of Web Applications

-- EMTA-INF Directory: stores System Description

-- WEB-INF Directory: consists of the following parts. Lib directory: Save the. jaror. ZIP file. Web. xml: Web application Initialization Configuration File. JSP file: the JSP file of the dynamic page.

3.2 Create A. jsp file

Right-click the webroot directory and choose new-JSP

In the pop-up dialog box, write a filename and click Finish. a jsp file is created.

3.3 insert simple Java code

Find the middle part of <body> </body>. Insert the following code:

<%= new java.util.Date() %>

In this line of code, <% = indicates the start of the expression, and %> indicates the end of the expression. Intermediate

new java.util.Date()

It can be the Java code that shows the current time.

3.4 web project deployment

JSP can run on the Tomcat server.

Click the deploy myeclipse j2eeproject to server button shown in.

In the pop-up box, select the current project name (my name is jsp1), and click Add

Select tomcat in server, click Finish, and click OK

3.5 start Tomcat

Click RUN/Stop/restart myeclipse next to deploy. Select tomcat-start. Wait until the Tomcat service is started.

You can see the successful Tomcat startup information in the console below. To run the. jsp page in a browser, Tomcat must be started.

3.6 run a. jsp page

Enter http: // localhost: 8080/jsp1/e1-ShowDate.jsp in the browser to see the displayed page.

(Jsp1 is the project name that Just configured tomcat, e1-ShowDate.jsp is the name of the JSP page to display)

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.