• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 842
  • Last Modified:

HttpRequest: cannot find symbol

I am programming a simple web server in Java, but can't get the HttpRequest class to work (or HttpRequestHeader, etc.)

It's probably something simple, as I"m new to Java.  Any idea how to make it find the class?  I'm using J2EE (J2SE didn't work either so I "upgraded" to no avail).

Big points because I'm in a hurry  :)

Thanks!!
Ross

=========
   OUTPUT
=========


C:\java>javac WebServer.java

WebServer.java:52: cannot find symbol
symbol  : class HttpRequest
location: class webserver.WebServer
                HttpRequest request = new HttpRequest(clientSocket);
                ^
WebServer.java:52: cannot find symbol
symbol  : class HttpRequest
location: class webserver.WebServer
                HttpRequest request = new HttpRequest(clientSocket);
                                          ^
2 errors

C:\java>



=======
  SOURCE
=======

/*
 * WebServer.java
 *
 * Created on May 17, 2006, 5:51 AM
 *
 */

package webserver;


import java.io.* ;
import java.lang.* ;
import java.net.* ;
import java.util.* ;


public final class WebServer
{
      public static void main(String argv[]) throws Exception
      {
           
            // Set the port number.
            int port = 6789;
                       
            // Establish the listen socket.
            ServerSocket serverSocket;
            try {
               serverSocket = new ServerSocket(port);
                }
            catch (IOException e) {
               System.out.println(e);
            }

            // Process HTTP service requests in an infinite loop.
            while (true) {
                               
                // Listen for a TCP connection request.
                Socket clientSocket = null;
                try {
                   clientSocket = serverSocket.accept();
                    }
                catch (IOException e) {
                   System.out.println(e);
                }

                // Construct an object to process the HTTP request message.
                HttpRequest request = new HttpRequest(clientSocket);

                // Create a new thread to process the request.
                Thread thread = new Thread(request);

                // Start the thread.
                thread.start();
               
            } // end while
           
        } // end main()
       
} // end WebServer class



//final class HttpRequest implements Runnable
//{
      //
//}
0
mistagitar
Asked:
mistagitar
  • 2
2 Solutions
 
InteractiveMindCommented:
..You've commented out the declaration of the HttpRequest class; so it cannot find it...
0
 
nayernaguibCommented:
The Java API does not contain an HttpRequest class. :-)

_______________

  Nayer Naguib
0
 
nayernaguibCommented:
Take a look at the following page for a sample implementation:

  http://www.adrem.ua.ac.be/~michiels/projects/HTTP/wwwroot/docu/source/

_______________

  Nayer Naguib
0
 
mistagitarAuthor Commented:
Ahhh, that would make sense.  I Googled it and just assumed the class in this page was native to Java's API:

    http://www.almaden.ibm.com/cs/wbi/doc/api/com/ibm/wbi/protocol/http/HttpRequest.html

Thanks all!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now