This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Tomcat and the fly likes running a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Reply locked New topic

running a servlet

adwin berkowits

Joined: Feb 23, 2012
Posts: 6
i wanted to ask if this is the proper way to compile and build a servlet in order to launch it via tomcat
becuase there is an additional index.jsp and i dont need it ,( i have a servlet to run)

if it is the proper way how can i run the servlet via the tomcat i use the tomcat installed by the netbeans

there is stuff on the internet but there is no documnet that guide for all the details needed to run a servlet
do i have to include the package of the project
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

Well, as I recently said, you don't "Launch" or "Run" a servlet. A servlet is not a stand-alone application, it's a class in a Web Application that contains methods that are invoked to process HTTP requests and return responses. It does not have an independent process/thread identity (and, in fact the J2EE standard forbids it), and therefore, except when the servlet's request handler method is being called, it's not running at all.

You should in no event be dependent on an IDE such as NetBeans to be able to use J2EE, if for no other reason that in the real world, production webservers do not run in IDEs, they run in stand-alone appservers. An even bigger problem is that you evidently don't understand what a web application truly is or how it's put together since you've been relying on Netbeans to do it for you.

All the details you need on how to create a web application and use servlets in web applications are written down in detail in numerous books and tutorials both in local bookstores and on the Internet. Some of these books are 10 years old now, and still fundamentally useful, others are more up-to-date.

The key is to stop thinking of servlets as "something Netbeans 'runs'" and start thinking of them as what they really are: components of web applications.

An IDE is no substitute for an Intelligent Developer.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

Also, this appears to be basically a continuation of a thread that you started in the IDE forum, so let's keep the conversation there. Running the same question in more than one forum causes a lost of confusion and wasted effort.
I agree. Here's the link:
subject: running a servlet
jQuery in Action, 3rd edition