aspose file tools*
The moose likes Servlets and the fly likes A servlet program not running successfully Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "A servlet program not running successfully" Watch "A servlet program not running successfully" New topic
Author

A servlet program not running successfully

Rohit Rawat Om
Greenhorn

Joined: Sep 18, 2009
Posts: 1
I'm a beginner to Servlets and I was running my first servlet program. Its a very simple code as shown below.



After compiling the result is " import javax.servlet.*; and import javax.servlet.http.*; packages do not exist. Other errors are there but they are related to these two.
jdk 1.6 is installed on my pc and I've done all the settings like setting environment and all and other prgms are successgully running.
When I unzipped the src file I found no servlet subpackage inside javax package. Is the problem because of this? If yes then how to get the servlet subpackage?
And what could be the other problem(s)?
Please help and thanks a lot in advance.


Rohit Rawat
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41808
    
  62
Welcome to JavaRanch.

For starters, you shouldn't extend GenericServlet, you should extend HttpServlet, and you shouldn't override service, but doGet or doPost.

The problem is that you need to add the servlet API jar file to your classpath. Since that is not part of JSE -as you've found out- you'll need to obtain it elsewhere. If you download JEE then it's included in that, or any servlet container (like Tomcat) also has it. You'll need a servlet container anyway to run servlets, so that's probably the easiest choice.


Ping & DNS - my free Android networking tools app
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

Also Rohit Use Code Tags when you post a source code. That way your code looks formatted. Unformatted code is hard to read. You can add code tags by wrapping your code in [code] [/code] tags. You can edit your message using button and then add code tags to it...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A servlet program not running successfully