File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes IDEs, Version Control and other tools and the fly likes Run Servlet In Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Run Servlet In Eclipse" Watch "Run Servlet In Eclipse" New topic

Run Servlet In Eclipse

Akmal Zahdi

Joined: Apr 09, 2005
Posts: 13
Hiii....I'm just finish study all tutorial in CodeBarn in this site. At the moment now I want to concentrate on Servlet and JSP. I'm using Eclipse as a tool in writing my code. I'm using this IDE because at my office, java expert using this IDE to do a project.

My question is, anybody know how to Run Servlet in Eclipse. Any body here is expert in Eclipse. Can u explain me step by step to Run the program or u could give me link that teach this thing to me. That's all from me. Tq.

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Hi Akmal,

I am going to move this thread to the IDE forum. A Copy will remain in this forum, but will be in a closed state, but anyone can click the link to get to the thread that will be in the IDE forum.

Good Luck


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Well here is the thing. A Servlet, the way it is supposed to be run, needs to run in a Web Server. Which basically means, no to your question.

However, there are other things you can do to "test" your Servlet running through Eclipse.

1. Remote Debugging, have the Servlet run in the Web Server, but have Eclipse hook into the Web Server for Remote Debugging. You can do a search on the JavaRanch Newsletter for remote debugging and find an article on how to set that up.

2. Mock Objects/Unit Tests. Using Mock Objects you can simulate a Web Container and pass fake Request and Response object to see how your Servlet runs.

I suggest both.

Good Luck

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17282

Actually, if you install the sysdeo Tomcat plugin, Eclipse will start an embedded copy of Tomcat to debug your servlet with. Just set breakpoints, do inspections, etc. just like normal.

The alternative is to deploy to an external servlet container (Tomcat, JBoss, WebWhoever, etc) that has been started with Remote Debugging enabled.

An IDE is no substitute for an Intelligent Developer.
Tugdual Grall

Joined: Jun 14, 2005
Posts: 3
You can also use the Lomboz plugin ( )

And here an example using OC4J as container:
How To Use Eclipse with Oracle Containers for J2EE (OC4J)

Akmal Zahdi

Joined: Apr 09, 2005
Posts: 13
Well thanks all esp 4 Mark Splitzer(coz for remove my topic here, sorry. dunno that have IDE thread ) , Tim Holloway n Tugdual Grall.

Now I can run my servlet in eclipse after asking help from my staff office. He show me step by step.

The step is :-

1) create tomcat project(I'm using eclipse SDK 3.0.1)

click File at menu bar, File > New > Project > choose Tomcat Project, click Next > give project name, click Next > show Tomcat Project Setting(URL address show on your browser), just click Finish.

2) A tomcat project created show a few files like WEB-INF/src, work, WEB-INF
and some sources TOMCAT. servlet files located in WEB-INF/src.

3) create servlet file in WEB-INF/src file

open folder project that created at 1 step, in that folder you can see 2 folders and 4 files. The folder is WEB-INF and work. click WEB-INF to open it.

4) Create XML Document as a path of servlet into the Browser.

example the document

u just need take care the Bold one, it is a path for servlet.

5) run ur server. Open ur local server home page, then extend it by the like this in ur browser.

localhost/project name/ file name

That's all from me. Tq. I'm writing this just for my refences(make this forum as my notes) and who want to starting learning servlet like me.
Akmal Zahdi

Joined: Apr 09, 2005
Posts: 13
Sorry the code project is here

[edited to escape < and >]
[ June 15, 2005: Message edited by: Jeanne Boyarsky ]
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32844

"Akmal Java",
We're pleased to have you here with us in the IDEs forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. I'm guessing your last name isn't "Java."

IDEs Forum Bartender
[ June 17, 2005: Message edited by: Jeanne Boyarsky ]

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Not to hijack this thread, but its related -

I downloaded the WTP plugin and installed it in the Eclipse plugins.
But I can't really fine a J2EE perspective. Not sure what I am missing.

Also, I don't see a 'Tomcat project' (to choose) like mentioned in the above posts.

Any pointes please.

- m

Take a Minute, Donate an Hour, Change a Life
I agree. Here's the link:
subject: Run Servlet In Eclipse
It's not a secret anymore!