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.
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.
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...