Creating Servlet In Myeclipse IDE


You want to comply with the subsequent steps to create the servlet withinside the myeclipse IDE.

Follow the steps given below:

  • Produce a Web project
  • Generate a html file
  • Generate a servlet
  • begin myeclipse tomcat server and installation project

1.Produce a web Project

Create a web project with the given steps: click on File Menu -> New -> web project -> write your project name e.g. first -> Finish.

2.Generate a html file:

The project is named as first, as you can see. Now, let's inspect this project more.

Steps to create a html file write click on WebRoot -> New -> html -> write your html file name e.g. MyHtml.html -> Finish.

The html file is created named MyHtml.html, as you can see above. Now, let's write the html code here.

3.Generate the Servlet:

Steps for creating a servlet are: click on File Menu -> New -> servlet -> write your servlet name e.g. Hello -> uncheck all the checkboxes except doGet() -> next -> Finish.

The servlet file is created as Hello.java. Now let's start writing the servlet code here.

Now, let's create the MyHtml.html file as the default page of your project. For this, you have to open a web.xml file and rename the welcome file name as MyHtml.html in place of index.jsp.

To see the source code you have to click on the source tab.

Now, substitute the welcome file name as MyHtml.html in the position of index.jsp.

4. Start the Server and deploy the project:

For beginning the server and deploying the project in a single step Right click on in your Project -> Run As -> MyEclipse server application.

The default port of myeclipse tomcat is 8080, when you have set up oracle in your system, the port no. will battle so let's first alternate the port range of myeclipse tomcat server. For converting the port number click on the begin server icon on the left hand side of browser icon -> myeclipse tomcat -> Configure server connector -> alter the port number as 8888 in place of 8080 -> apply -> ok.

Again alter the post number as 8888 in place of 8080- then apply- ok

Now the post number is being replaced. Steps for starting a server Right click on your project -> Run As -> MyEclipse server application.

Now, the default page of your project is opened as you can see, Write your name, then click on Go.