Results 1 to 15 of 15
  1. #1
    aks_1 is offline Member
    Join Date
    Apr 2010
    Posts
    16
    Rep Power
    0

    Default compile java servlet

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

    public class HowdyServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    PrintWriter out=response.getWriter();
    response.setContentType("text/html");
    out.println("<html>");
    out.println("<body>");
    out.println("<center><h1>Howdy</h1></center>");
    out.println("</body>");
    out.println("</html>");
    }
    }
    the above program could not be compiled
    C:\> javac HowdyServlet.java
    showed error in http classes and its objects
    any advise?

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Pleas DO NOT post the same question in multiple sub-forum. If you want to move it to different place contact one of our moderators. Please pay your attention on that, otherwise you may ban in out forum.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Just notice that the following in your code, which is incorrect.

    Java Code:
    whimport java.io.*;

  5. #5
    aks_1 is offline Member
    Join Date
    Apr 2010
    Posts
    16
    Rep Power
    0

    Default ompile a servlet program

    thank you for replying.
    i have found the solution.
    i did not know that to compile a servlet program you need to have servlet.jar
    exe to execute it.
    many thanks..

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    If you think how these two comes,

    Java Code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    then you are able to fine the solution earlier. And also keep in mind that servlet.jar is a JAR package not an exe. Better to use the correct wording on those things lol.

  7. #7
    aks_1 is offline Member
    Join Date
    Apr 2010
    Posts
    16
    Rep Power
    0

    Default java servlet problem

    i am trying to compile java servlet program.
    i have set classpath=.;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet.jar.
    some days back it was working perfectly but now suddenly it's not working.
    please help!

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  9. #9
    aks_1 is offline Member
    Join Date
    Apr 2010
    Posts
    16
    Rep Power
    0

    Default

    i have done that before too.
    the problem was with the import statement.
    i had used package name java instead of javax.
    now you can know how stupid i am when it comes to programming.
    thanks.

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    That's what I've pointed in previous posts. Anyway, if you've solved the problem please mark it in the thread.

  11. #11
    aks_1 is offline Member
    Join Date
    Apr 2010
    Posts
    16
    Rep Power
    0

    Default

    I read all your post seriously but you will think why i don't follow them.
    I am actually new and so engrossed the problems i post that i forget.
    I am sorry and please consider it as my Sincere apology.
    Now for your current post, i don't know how to mark post as SOLVED.
    Your guidance is required.

  12. #12
    aks_1 is offline Member
    Join Date
    Apr 2010
    Posts
    16
    Rep Power
    0

    Default

    I got it.
    THANKS

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by aks_1 View Post
    I read all your post seriously but you will think why i don't follow them.
    Of course not. I've not mean that, I just want to say that what you've doing wrong in your code segment.

  14. #14
    aks_1 is offline Member
    Join Date
    Apr 2010
    Posts
    16
    Rep Power
    0

    Default

    okay.
    thanks

  15. #15
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. .java won't compile
    By paul21 in forum New To Java
    Replies: 4
    Last Post: 03-30-2010, 07:58 AM
  2. Compile and Run a Java package
    By hussain in forum New To Java
    Replies: 1
    Last Post: 09-10-2009, 10:15 AM
  3. compile servlet in JCreator
    By kiki2009 in forum JCreator
    Replies: 0
    Last Post: 08-03-2009, 03:22 PM
  4. My Java program will not compile and run?
    By sabrown311313 in forum Java Applets
    Replies: 1
    Last Post: 09-23-2008, 10:38 AM

Posting Permissions

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