Deploy JSP in myeclipse

Source: Internet
Author: User

1. Open the myeclipse development interface, file-> New-> projects... Open the Create Project dialog box, select myeclipse-> J2EE projects-> Web project, and enter webtest in the projects Name of project details. The default value is used for other projects, note that the context root URL here is/webtest. Otherwise, you must use it in IE. Check whether the tag library is supported at the bottom. Choose jstl1.1. Click Finish to create the project.
We can see that the classes required for the new project have been automatically loaded, and there is also a J2EE class environment variable, which is convenient to use myeclipse.
2. Create a "hello" class and select the SRC folder under the project webtest (Note: If this folder cannot be found under package explorer, go to the eclipse User Guide, window Kage Explorer ), right-click a package and choose new> package to create a new package. specified resky. bean. Select the new package, right-click the New-> class, and enter the static void main option in name. All others are default. Click Finish to create the class.
The Edit class code is as follows:
Package com. Alibaba resky. Bean;
/** Junsan * */
Public class hello
{Private string message = "Hello World ";
/*** @ Return returns the message .*/
Public String getmessage ()
{Return message ;}
/*** @ Param message the message to set .*/
Public void setmessage (string message)
{This. Message = message ;}}
Note that the bean attribute operation method can define the attribute first. Then, in the editing window, right-click the menu source-> Generate getters and setters, and select the property of the get and set methods to be generated.
3. Create a JSP page
In the webtest project, select the webroot folder, right-click the menu New-> JSP, and change file name to index. jsp. By default, click Finish and press
Edit the content of the JSP file as follows:
<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "UTF-8" %>
String Path = request. getcontextpath ();
String basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/";
<JSP: usebean id = "hello" class = "com. Alibaba resky. Bean. Hello" Scope = "page"/>
<JSP: setproperty name = "hello" property = "message" value = "Hello world! "/>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional/
Welcome to and add this article to your favorites [1] [2] [3]
$ False $
/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 is my page">
<! --
<LINK rel = "stylesheet" type = "text/CSS" href = "styles.css">

<JSP: getproperty name = "hello" property = "message"/> <br>
This is my JSP page. <br>

Note that the red part is the code we added. Well, our code has been compiled.
4. Configure the Tomcat server
Eclipse menu, window-> preference... In the preference dialog box, locate "myeclipse-> application servers-> tomcatat" in the menu tree, select "enable" in the dialog box, and click "Browse" in the Tomcat home directory input box, select the tomcat installation root object omcat5.5. the other boxes are automatically filled. Click Apply. Select JDK in Tomcat 5. Note that the default runtime environment is JRE. Set JDK here. Otherwise, myeclipse will not work properly.
The Tomcat server cannot run normally.
Click the Add button to write JDK 1.5.0 _ 06 to the JRE name, and select the JDK root directory in the Browse selection box. Here is C:/program files/Java/jdk1.5.0 _ 0 6, for other default values, click OK. In Tomcat JDK name, select the one we just created, that is, jdk1.5.0 _ 06. Click the Apply button. Every time you click e, a problem occurs. If you do not click this button to go to another configuration page, the above configuration will be lost.
Make sure that the debug mode is selected in the launch of Tomcat 5.
In paths, there are some class path settings. The first is the class path loaded in advance. Some packages are used only when the server is started to initialize the web application; the third is the class that is not packaged. We don't care about it here.
Now you can click the OK button in the preference dialog box to complete tomcat configuration. Welcome to. Click here for more articles and tutorials [1] [2] [3]
VII. Subordinate Web Applications
This is simple. Select the root directory of the webtest project, right-click the menu myeclipse-> add and remove projects deployments... Make sure projects is webtest. Click Add. In the displayed dialog box, select Tomcat 5 as the server. The following two single options are exploaded archive and directory-based and package-based, this is done by myeclipse. We do not need to compress the war package by using the directory deployment method, and the rest will return to the previous page regardless of its button.
If the server is specified, deploy the Application below. Select the five items in the server list in the dialog box. The dimmed button becomes available. Remove is used to remove deployment and redeploy. Click redeploy, you can click this button to redeploy the modified project. Click here.
OK. The program has been deployed. Run and debug the program below.
5. Run the debugging program
In the eclipse graphic menu bar (the "Redeploy" button on the left and the "self-dropping" browser on the right), click the drop-down button, and then click the Start menu to start Tomcat. When the Consol window prompts that Tomcat is successfully started, we can run our program. Open an IE browser window and enter http: // localhost: 8080/webtest/. The following information is displayed:
Hello world!
This is my JSP page. It indicates that the operation is successful.


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: 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.