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

please help me

shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
hi !
I have just passed SCJP. I wanted to learn servlets and other technologies so i downloaded
the jsdk2.1 package. And i also given the path in the bat file. But still when i compile any basic servlet program it is giving me error that javax.servlet does not exist. I don't know why it is giving me these types of errors.Thanks in advance.
Ashwin Desai
Ranch Hand

Joined: Jul 17, 2000
Posts: 124
Hi,
You have to add the servlet jar files to your CLASSPATH.
Refer to the instructions (html file that comes along with jswdk) for details.
Ashwin.
gayatri reddy
Greenhorn

Joined: Apr 25, 2001
Posts: 7
hi shabbir,
installing only jsdk is not sufficient u have install any application server that support servlets like tomcat,java web server,jrun ....so decide which server u want to use and install it.if u know java then it is quite easy to work on servlets.
-greddy
gayatri reddy
Greenhorn

Joined: Apr 25, 2001
Posts: 7
hi shabbir,
sorry i thought u installed jdk instead of jsdk.
-greddy
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Shabir,

Congratulations on clearing the SCJP exam.Please read the documentation of JSDK 2.1 for configuration of the classpath.You can put the servlet.jar in the classpath or alternatively put it in jre/lib/ext folder, so that JVM can take care of your servlet compilation/execution.
Hope this helps.
Regards,
------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
thanks everybody for your replies.
shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
hi guys!

Thanks for your replies but i did everything i configured jsdk server and jsdk servlet.
but now when i compile any file it gives me error that HelloServlet.java:4 cannot resolve symbol:class GenericServlet
location:class HelloServlet

this is my source code.
import java.io.*;

public class HelloServlet extends GenericServlet {

public void service(ServletRequest request,ServletResponse response)
throws ServletException,IOException {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<b>Hello!");
pw.close();
}
}

Now guys please help to solve this error.
shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
hi guys!

Thanks for your replies but i did everything i configured jsdk server and jsdk servlet.
but now when i compile any file it gives me error that HelloServlet.java:4 cannot resolve symbol:class GenericServlet
location:class HelloServlet

this is my source code.
import java.io.*;

public class HelloServlet extends GenericServlet {

public void service(ServletRequest request,ServletResponse response)
throws ServletException,IOException {
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<b>Hello!");
pw.close();
}
}

Now guys please help to solve this error.
Shibin Raghavan
Greenhorn

Joined: Mar 29, 2001
Posts: 11
Hi Shabbir,
U have to import the 'javax.servlet.*' package into ur program. So, just include this line into ur program:
include javax.servlet.*;
and then compile. It must work.
Regards,
Shibin
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Shabbir,
I would suggest, you import javax.servlet.http.*, and javax.servlet.* both.The former for HttpServlet class and the latter for ServletException class
Also, it is a common practice not to override the service method, unless you are implementing a new protocol like HTTP.
Hence, you could try the following code :

Hope this helps.
Regards,

------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
Shibin Raghavan
Greenhorn

Joined: Mar 29, 2001
Posts: 11
Sorry Shabbir for the error in my previous reply.
The actual line must be:
import javax.servlet.*;
I just typed 'include' by mistake instead of import.
Regards,
Shibs
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please help me