How To Create Servlet in MyEclipse IDE - Javatpoint
How To Create Servlet in MyEclipse IDE - Javatpoint
CreatingServletinmyeclipseIDE
You need to follow the following steps to create the servlet in the
myeclipseIDE.Thestepsareasfollows:
Createawebproject
createahtmlfile
createaservlet
startmyeclipsetomcatserveranddeployproject
downloadthisexample
1)Createthewebproject:
ForcreatingawebprojectclickonFileMenu>New>webproject>
writeyourprojectnamee.g.first>Finish.
1/14
5 /2/2016
2/14
5 /2/2016
2)Createthehtmlfile:
Asyoucanseethataprojectiscreatednamedfirst.Nowlet'sexplore
thisproject.
3 /14
5 /2/2016
For creating a html file, right click on WebRoot > New > html > write
yourhtmlfilenamee.g.MyHtml.html>Finish.
4/14
5 /2/2016
AsyoucanseethatahtmlfileiscreatednamedMyHtml.html.Nowlet's
writethehtmlcodehere.
5 /14
5 /2/2016
3)Createtheservlet:
ForcreatingaservletclickonFileMenu>New>servlet>writeyour
servletnamee.g.Hello>uncheckallthecheckboxesexceptdoGet()
>next>Finish.
6/14
5 /2/2016
As you can see that a servlet file is created named Hello.java. Now
let'swritetheservletcodehere.
7/14
5 /2/2016
Now let's make the MyHtml.html file as the default page of our project.
For this, open web.xml file and change the welcome file name as
MyHtml.htmlinplaceofindex.jsp.
8 /14
5 /2/2016
Clickonthesourcetabtoseethesourcecode.
NowchangethewelcomefileasMyHtml.htmlinplaceofindex.jsp.
9/14
5 /2/2016
4)Starttheserveranddeploytheproject:
ForstartingtheserveranddeployingtheprojectinonestepRightclick
onyourproject>RunAs>MyEclipseserverapplication.
The default port of myeclipse tomcat is 8080, if you have installed
oracle on your system, the port no. will conflict so let's first change the
portnumberofmyeclipsetomcatserver.Forchangingtheportnumber
h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide
10/14
5 /2/2016
click on the start server icon at the left hand side of browser icon >
myeclipse tomcat > Configure server connector > change the port
numberas8888inplaceof8080>apply>ok.
Nowchangetheportnumberas8888inplaceof8080>apply>ok.
11/14
5 /2/2016
Nowportnumberhavebeenchanged.ForstartingtheserverRightclick
onyourproject>RunAs>MyEclipseserverapplication.
12/14
5 /2/2016
As you can see that default page of your project is open, write your
name>go.
13 /14
5 /2/2016
downloadthisexample
<<prev
Share
next>>
14/14