Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 18th, 2006, 10:13 PM
Registered User
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to discuss
Default servlet Problem


hi


ONe problem i am facing..

I am using Fedora Core 4 Linux O.S.

I am trying to run HelloWorld.java it's servlet program but it doesn't work.

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

public class HelloWorld extends HttpServlet {

  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {

    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    out.println("<HTML>");
    out.println("<HEAD><TITLE>Hello World</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("<BIG>Hello World</BIG>");
    out.println("</BODY></HTML>");
  }
}

When i compiled with javac HelloWorld.java
it gives ERRORS

1. ERROR in HelloWorld.java
 (at line 4)
        import javax.servlet.*;
               ^^^^^^^^^^^^^
The import javax.servlet cannot be resolved
----------
2. ERROR in HelloWorld.java
 (at line 5)
        import javax.servlet.http.*;
               ^^^^^^^^^^^^^
The import javax.servlet cannot be resolved
----------
3. ERROR in HelloWorld.java
 (at line 7)
        public class HelloWorld extends HttpServlet {
                                        ^^^^^^^^^^^
HttpServlet cannot be resolved to a type
----------
4. ERROR in HelloWorld.java
 (at line 9)
        public void doGet(HttpServletRequest req, HttpServletResponse res)
                          ^^^^^^^^^^^^^^^^^^
HttpServletRequest cannot be resolved to a type
----------
5. ERROR in HelloWorld.java
 (at line 9)
        public void doGet(HttpServletRequest req, HttpServletResponse res)
                                                  ^^^^^^^^^^^^^^^^^^^
HttpServletResponse cannot be resolved to a type
----------
6. ERROR in HelloWorld.java
 (at line 10)
        throws ServletException, IOException {
               ^^^^^^^^^^^^^^^^
ServletException cannot be resolved to a type
----------
6 problems (6 errors)

-------------------------------------------------------------------------------------

Now the question is how to set servlet with jdk..? that i don't know..
please explain in detail...

please request you to give me the clue.

For your kind information i am running tomcat5 servers with servlet examples perfectly.

but once i create my own java file it doesn't work..

once again request you to please explain with details how to set class path with which file system, i have to go and set it.

Thanking you

regards
nirlep patel


Thanks
 
Old August 21st, 2006, 04:22 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Nirlep,

Just add servlet.jar to your classpath.

Jon Emerson
http://www.jonemerson.net/
 
Old August 24th, 2006, 05:57 AM
Registered User
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to discuss
Default

thanks , i did it


Thanks
 
Old February 6th, 2007, 02:06 PM
Registered User
 
Join Date: Feb 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by panacea
 Hi Nirlep,

Just add servlet.jar to your classpath.

Jon Emerson
http://www.jonemerson.net/
I too got the same problem with the servlet
Can u explain me in detail HOW TO ADD SERVLET.JAR TO CLASSPATH
i have insatalled tomcat 5
I have read in a book that the JAVA_HOME variable has to be given the path of java where it has been installed
I found java in /usr/bin/share/java
Do i need to set a value to this variable?? If yes Please explain me how to do?

Bye Waiting for a nice reply







Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with servlet developer.ibm Servlets 1 September 12th, 2007 11:22 PM
Servlet Problem cziaul Servlets 2 April 28th, 2007 09:39 AM
My servlet problem saeed Servlets 1 April 10th, 2007 07:12 AM
servlet problem discuss Servlets 1 August 29th, 2006 10:03 AM
Servlet problem Ravi Kumar Servlets 1 June 20th, 2005 04:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.