| Author |
problem working on Servlets..plz help..
|
Sonu Kaur
Greenhorn
Joined: Sep 30, 2004
Posts: 9
|
|
i was trying to compile a simle servlet by giving the command javac -classpath c:\Tomcat5.0\common\lib\servlet-api.jar -d classes c:\pr1\src\chservlet.java why am i getting the error.. package..javax.servlet doesnt exist.. plz help me out..
|
 |
Sonny Gill
Ranch Hand
Joined: Feb 02, 2002
Posts: 1211
|
|
Jaismeen, What it means is that the Servlet API classes are not being found on your classpath. May be there is some spelling mistake in the classpath you specify. or you may want to copy servlet-api.jar (make sure it contains the 'servlet' classes, just in case) to a specially created directory for jars, such as c:\jars, and set the classpath to that location. cheers Sonny
|
 |
Ramaswamy Srinivasan
Ranch Hand
Joined: Aug 31, 2004
Posts: 295
|
|
Hi Jaismeen, Your problem is pertaining to the class path not being set to the place where the servlet.jar file is located. In your system, go to 1. CATALINA_HOME/commons/lib directory. 2. Check whether the servlet.jar file is existing. 3. If it is there, set the Environment variable classpath = %CATALINA_HOME%\commons\lib\servlet.jar; 4. Restart your Tomcat... It should work fine. If you don't have, just load the servlet.jar down and place it in ur lib directory. That should work. In case of troubles, you know where to come. Cheers, Swamy
|
 |
Sonu Kaur
Greenhorn
Joined: Sep 30, 2004
Posts: 9
|
|
sorry guys..for starting each time new thread..just registered myself to the site yesterday after facing this problem..so cudnt get familiar with its working.. i have given the commands as follows.. set classpath=c:\Tomcat5.0\common\lib\servlet-api.jar,%classpath% set path=c:\jsdk1.4\bin;%path% javac c:\pr1\src\chservlet.java getting the following errors C:\>javac c:\pr1\src\chservlet.java c:\pr1\src\chservlet.java:1: package javax.servlet does not exist import javax.servlet.*; ^ c:\pr1\src\chservlet.java:2: package javax.servlet.http does not exist import javax.servlet.http.*; ^ c:\pr1\src\chservlet.java:5: cannot resolve symbol symbol : class HttpServlet location: class chservlet public class chservlet extends HttpServlet ^ c:\pr1\src\chservlet.java:7: cannot resolve symbol symbol : class HttpServletRequest location: class chservlet public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOExcep tion ^ c:\pr1\src\chservlet.java:7: cannot resolve symbol symbol : class HttpServletResponse location: class chservlet public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOExcep tion ^ 5 errors was just wondering.ihave windows xp..so does it effect in anyway(it shud not) and if name of the servlet is given wrong then it shudnt give these set of errors..it shud give kind a"cudnt find the file name" and i have checked the classpath..servlet-api.jar is present and is in this location c:\Tomcat 5.0\common\lib and i had tried giving the command jar -tvf servlet-api.jar.. it gives the list of classes..which shows..its present in the directory jdk is present in c:\jsdk1.4 location of servlet is c:\pr1\src\chservlet.java servlet code is as follows import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class chservlet extends HttpServlet { public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException { PrintWriter out =res.getWriter(); java.util.Date today= new java.util.Date(); out.println("<html>"+ "<body>"+ "<h1 align=center>HF\'s Chapter1 Servlet<h1>" +"<br>"+today+"</body>"+"</html>"); } } even i tried copynig servlet-api.jar in the same directory as the servlet and compiling it.. it gives the same set of errors am just wondering what cud be the problem.sure..must b very smal..but i m not progressing much regards
|
 |
Sheldon Fernandes
Ranch Hand
Joined: Aug 18, 2004
Posts: 157
|
|
You need to have semicolons separating the folders/jars in your classpath. You currently have a comma. set classpath=c:\Tomcat5.0\common\lib\servlet-api.jar;%classpath% Also, is there a space between Tomcat and 5.0? Is it Tomcat5.0 or Tomcat 5.0? Small things like these matter. Sheldon Fernandes [ October 01, 2004: Message edited by: Sheldon Fernandes ]
|
 |
Sonu Kaur
Greenhorn
Joined: Sep 30, 2004
Posts: 9
|
|
thnx i got the servlet compiled..very true.. ..the very small thing which was bothering..was a space between Tomcat 5.0 regards
|
 |
 |
|
|
subject: problem working on Servlets..plz help..
|
|
|