Forums Register Login

package javax.servlet does not exist... Please help me..

+Pie Number of slices to send: Send
Hi All;

i have set classpath enviornment var as..


.; C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;

i am using tomcat 5.0 and jdk1.5



my simple servlet is..



import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

class NewServlet extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
res.setContentType("text/html");
PrintWriter out =res.getWriter();

out.println("<html>");
out.println("<body>");
out.println("hi how are u");
out.println("</body>");
out.println("</html>");
}
}



and errors are...



C:\>javac NewServlet.java
NewServlet.java:1: package javax.servlet does not exist
import javax.servlet.*;
^
NewServlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
NewServlet.java:5: cannot find symbol
symbol: class HttpServlet
class NewServlet extends HttpServlet
^
NewServlet.java:7: cannot find symbol
symbol : class HttpServletRequest
location: class NewServlet
public void doPost(HttpServletRequest req, HttpServletResponse res)
^
NewServlet.java:7: cannot find symbol
symbol : class HttpServletResponse
location: class NewServlet
public void doPost(HttpServletRequest req, HttpServletResponse res)
^
5 errors

Please help me. i am trying since last 2 days but i have not able to resolve the errors. i think enviornment var is not accesible , what i need to do, please reply me soon.
+Pie Number of slices to send: Send
You can check the value of CLASSPATH by typing "echo %CLASSPATH%".

If you can't get that to work, try

javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;." NewServlet.java
+Pie Number of slices to send: Send
hi Ulf Dittmer,
thanks for reply.

while using echo %CLASSPATH% the classpath of jar file is shown on the prompt, but why it is not available in servlet through enviornment var.
and your 2nd option working.
can you please tell me how to access enviornment variable

thanks in advance

---
Anurag
+Pie Number of slices to send: Send
Moving to Java In General (Beginner) where javac and CLASSPATH issues are discussed.
+Pie Number of slices to send: Send
 

Originally posted by anuragk kushwaha:
can you please tell me how to access enviornment variable


The JDK installation notes explain how to edit environment variables on different versions of Windows. (I assume you're using Windows).
You may have just won ten million dollars! Or, maybe a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1158 times.
Similar Threads
my first servlet not Compiling
servlet class not compiling. Classpath problem?
Exception during compiling servlet
Servlet basic program
How To Compile Servlet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:35:38.