• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

simple servlet program error

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check our FAQ.
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's explained in the FAQ.
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you set your CLASSPATH ?
 
Arun raghvan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CLASSPATH=;.;F:\Java\jdk1.6.0_03\lib\tools.jar;F:\glassfishv3\glassfish\lib\javaee.jar
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to move to the directory where your class is.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what an idiotic programmer ..I AM!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thankyou! Christophe Verré and Bear Bibeault
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since i didn't have a Computer ... with that problem and a part of LAziness !!!
 
We cannot change unless we survive, but we will not survive unless we change. Evolving tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic