Sunteți pe pagina 1din 14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

Cont ent Menu

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.

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

1/14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

2/14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

2)Createthehtmlfile:
Asyoucanseethataprojectiscreatednamedfirst.Nowlet'sexplore
thisproject.

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

3 /14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

For creating a html file, right click on WebRoot > New > html > write
yourhtmlfilenamee.g.MyHtml.html>Finish.

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

4/14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

AsyoucanseethatahtmlfileiscreatednamedMyHtml.html.Nowlet's
writethehtmlcodehere.

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

5 /14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

3)Createtheservlet:
ForcreatingaservletclickonFileMenu>New>servlet>writeyour
servletnamee.g.Hello>uncheckallthecheckboxesexceptdoGet()
>next>Finish.

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

6/14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

As you can see that a servlet file is created named Hello.java. Now
let'swritetheservletcodehere.

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

7/14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

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.

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

8 /14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

Clickonthesourcetabtoseethesourcecode.

NowchangethewelcomefileasMyHtml.htmlinplaceofindex.jsp.

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

9/14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

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

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

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.

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

11/14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

Nowportnumberhavebeenchanged.ForstartingtheserverRightclick
onyourproject>RunAs>MyEclipseserverapplication.

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

12/14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

As you can see that default page of your project is open, write your
name>go.

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

13 /14

5 /2/2016

H ow t o creat e Servlet in M yEclipse IDE - javat poin t

downloadthisexample

<<prev

Share

next>>

h t t p://www.javat poin t .com /creat in g-servlet -in -m yeclipse-ide

14/14

S-ar putea să vă placă și