?
Solved

HttpRequest:  cannot find symbol

Posted on 2006-05-17
4
Medium Priority
?
807 Views
Last Modified: 2013-11-13
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
Comment
Question by:mistagitar
  • 2
4 Comments
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 16699833
..You've commented out the declaration of the HttpRequest class; so it cannot find it...
0
 
LVL 14

Accepted Solution

by:
nayernaguib earned 1000 total points
ID: 16699851
The Java API does not contain an HttpRequest class. :-)

_______________

  Nayer Naguib
0
 
LVL 14

Assisted Solution

by:nayernaguib
nayernaguib earned 1000 total points
ID: 16699884
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
 

Author Comment

by:mistagitar
ID: 16705654
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Six Sigma Control Plans
Progress

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question