wood burning stoves 2.0*
The moose likes Servlets and the fly likes please help...new to servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "please help...new to servlets" Watch "please help...new to servlets" New topic
Author

please help...new to servlets

san geeta
Greenhorn

Joined: Jan 28, 2004
Posts: 1
my java version is j2sdk1.4.1_03.I have saved the servlet in bin subdirectory..Tomcat is properly initialised because the index page opens...But when i try to compile the servlet i get the following errors...please tell me where the problem lies.....

C:\j2sdk1.4.1_03\bin>javac MyFirstServlet.java
MyFirstServlet.java:4: package javax does not exist
import javax.servlet;
^
MyFirstServlet.java:5: package javax.servlet.htt does not exist
import javax.servlet.htt.HttpServletRequest;
^
MyFirstServlet.java:6: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletResponse;
^
MyFirstServlet.java:8: package javax.servlet does not exist
import javax.servlet.ServletExcetion;
^
MyFirstServlet.java:10: cannot resolve symbol
symbol : class HttpServlet
location: class MyFirstServlet
public class MyFirstServlet extends HttpServlet
^
MyFirstServlet.java:12: cannot resolve symbol
symbol : class HttpServletRequest
location: class MyFirstServlet
public void doGet(HttpServletRequest request, HttpServletResponse respon
se) throws ServletException, IOException
^
MyFirstServlet.java:12: cannot resolve symbol
symbol : class HttpServletResponse
location: class MyFirstServlet
public void doGet(HttpServletRequest request, HttpServletResponse respon
se) throws ServletException, IOException
^
MyFirstServlet.java:12: cannot resolve symbol
symbol : class ServletException
location: class MyFirstServlet
public void doGet(HttpServletRequest request, HttpServletResponse respon
se) throws ServletException, IOException
^
8 errors
the servlet program is::

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet;
import javax.servlet.htt.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletExcetion;
public class MyFirstServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException
{
response.setContentType("text/plain");
PrintWriter out = response.getWriter();
out.println("This is my first servlet");
}
}
Srinivasan Mani
Ranch Hand

Joined: Apr 03, 2002
Posts: 36
You need to have j2ee.jar in your classpath.
Srinivasan Mani
Ranch Hand

Joined: Apr 03, 2002
Posts: 36
In case of tomcat, add
tomcat_home\common\lib\servlet.jar to classpath and then compile.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please help...new to servlets
 
Similar Threads
compilation error while running simple servlet code
problem with TOMCAT_HOME configration
problem in compiling servlet
error with compiling servlet
java don't compile my servlet.