• Post Reply Bookmark Topic Watch Topic
  • New Topic

simple servlet program error

 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It says package javax.servlet.http does not exist ..i don't no how to solve this



Error:

---------- Compile Java Source ----------
HelloServlet.java:1: package javax.servlet.http does not exist
import javax.servlet.http.HttpServlet;
^
HelloServlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletRequest;
^
HelloServlet.java:3: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletResponse;
^
HelloServlet.java:6: cannot find symbol
symbol: class HttpServlet
public class HelloServlet extends HttpServlet
^
HelloServlet.java:8: cannot find symbol
symbol : class HttpServletRequest
location: class HelloServlet
public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException
^
HelloServlet.java:8: cannot find symbol
symbol : class HttpServletResponse
location: class HelloServlet
public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException
^
HelloServlet.java:10: cannot find symbol
symbol : variable rep
location: class HelloServlet
rep.setContentType("text/html");
^
HelloServlet.java:11: cannot find symbol
symbol : variable rep
location: class HelloServlet
PrintWriter out=rep.getWriter();
^
8 errors

Output completed (1 sec consumed) - Normal Termination
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check our FAQ.
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i downloaded

Java EE 6 SDK Update 1 (with JDK 6 U20)
java_ee_sdk-6u1-jdk-windows.exe

but how to set the path?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's explained in the FAQ.
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even after i included CLASSPATH ..i keep on getting the same error.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you set your CLASSPATH ?
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CLASSPATH=;.;F:\Java\jdk1.6.0_03\lib\tools.jar;F:\glassfishv3\glassfish\lib\javaee.jar
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read TellTheDetails. Making the people trying to help you pull teeth to get information is not the best way to persuade them to help you.
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is your CLASSPATH starting with a semicolon ?
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Semicolon is Not required!!And even if you add Semicolon nothing happens.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when you try "javac -classpath F:\glassfishv3\glassfish\lib\javaee.jar HelloServlet.java" ?
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i get the following error :
javac:file not found:HelloServlet.java
HelloServletError.jpg
[Thumbnail for HelloServletError.jpg]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to move to the directory where your class is.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To learn how to compile classes, check the "Hello World!" for Microsoft Windows tutorial. I think that you should understand how to compile and run programs before starting servlets.
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yea thanks ! Now tell me this after i compile i get this 2 errors
ninagi.jpg
[Thumbnail for ninagi.jpg]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please copy and paste the errors as text rather than screen captures.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arun raghvan wrote:yea thanks ! Now tell me this after i compile i get this 2 errors

You also need to study basic Java before getting into servlets. Where does this "rep" variable come from ? It should be "res".
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what an idiotic programmer ..I AM!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arun raghvan wrote:what an idiotic programmer ..I AM!

No, you're learning But I think that you should start from the beginning instead of going straight to web applications.
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i completed HEAD FIRST JAVA ...i wonder how forget these concepts.
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually they say Code ..Code and Code. "I must have listened to this"
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou! Christophe Verré and Bear Bibeault
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arun raghvan wrote:Usually they say Code ..Code and Code. "I must have listened to this"

Yes. There's nothing like hands-on exercises.
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since i didn't have a Computer ... with that problem and a part of LAziness !!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!