Java Query
Results 1 to 3 of 3

Thread: Java Query

  1. #1
    Senior Member kingkong's Avatar
    Join Date
    Oct 2007
    Location
    UAE
    Posts
    197

    Java Query

    Hi AO's

    Well i am new to java programming

    and i was writing a new program in java servlet which is

    // Hello.java
    import java.io.*;
    import javax.servlet.*;

    public class Hello extends GenericServlet {
    public void service(ServletRequest request, ServletResponse response)
    throws ServletException, IOException
    {
    response.setContentType("text/html");
    PrintWriter pw = response.getWriter();
    pw.println("Hello, world!");
    pw.close();
    }
    }
    and while compiling in CMDi got error as follows
    C:\Program Files\Java\jdk1.6.0_06\bin>javac Hello.java
    Hello.java:3: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    Hello.java:5: cannot find symbol
    symbol: class GenericServlet
    public class Hello extends GenericServlet {
    ^
    Hello.java:6: cannot find symbol
    symbol : class ServletRequest
    location: class Hello
    public void service(ServletRequest request, ServletResponse response)
    ^
    Hello.java:6: cannot find symbol
    symbol : class ServletResponse
    location: class Hello
    public void service(ServletRequest request, ServletResponse response)
    ^
    Hello.java:7: cannot find symbol
    symbol : class ServletException
    location: class Hello
    throws ServletException, IOException
    ^
    5 errors

    C:\Program Files\Java\jdk1.6.0_06\bin>
    what does this error resembles to
    Last edited by kingkong; June 8th, 2008 at 08:41 AM. Reason: modification
    Question is not "Why are you Online"
    Question is "Why are you Off line"

  2. #2
    Custom User
    Join Date
    Oct 2001
    Posts
    503
    Am I right in thinking that javax.servlet is a Tomcat package (I get the feeling there might be different implementations)? Basically the error you're getting means that the Java compiler can't find the javax.servlet package. This means either:

    1. You don't have the package, or
    2. Your classpath isn't set up to include the servlet package.

    If you have the first problem, go to http://tomcat.apache.org/ and download. If you have the second problem, find where the servlet package is installed and add it to your classpath. For info on setting the classpath correctly, see http://java.sun.com/j2se/1.3/docs/to...classpath.html.

    Hope that sorts you out - just bear in mind that I'm not really a Java person, so if there's anything wrong with what I've told you, that's why.

    Cheers,
    ac

  3. #3
    Senior Member kingkong's Avatar
    Join Date
    Oct 2007
    Location
    UAE
    Posts
    197
    Hi Gothic Type,

    I got the error i read alot on java site and finally i got the answer for that stupid question i asked

    i am using JAVA SE which do not have the package of javax.servlet and because of which i got this error i should use Java EE

    as per i am new to java and still my teacher of the class thought of teaching me javax.servlet , swing , and applets

    on which i heard should be teached on the later stage after i got my hand properly on the pace of java

    Thanks a lot for your answer
    Gothic
    Question is not "Why are you Online"
    Question is "Why are you Off line"

Similar Threads

  1. Men speak C, Women speak Java.
    By MrLinus in forum Cosmos
    Replies: 4
    Last Post: April 18th, 2004, 08:01 AM
  2. The history of the Mac line of Operating systems
    By gore in forum Operating Systems
    Replies: 3
    Last Post: March 7th, 2004, 07:02 AM
  3. Java chat sessions....a query
    By vozhan in forum AntiOnline's General Chit Chat
    Replies: 1
    Last Post: March 6th, 2004, 08:49 PM
  4. Foot Printing with Host
    By SonofGalen in forum The Security Tutorials Forum
    Replies: 7
    Last Post: February 9th, 2004, 10:14 AM
  5. Difference between Java and JavaScript
    By Remote_Access_ in forum Security Archives
    Replies: 4
    Last Post: January 3rd, 2002, 10:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides