This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Anuragk kushwaha
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anuragk kushwaha
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Java In General (Beginner) where javac and CLASSPATH issues are discussed.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!