Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

web server HELP

  Asked By: Kiral    Date: Jul 30    Category: Java    Views: 729
  

im trying to do a multi threaded web server in java. Im having
trouble knowing what to put at the bottom of my code where i have
placed the question marks. If anyone can have a look and please help
me i would really love it.


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

public final class WebServer
{
public static void main(String argv[]) throws Exception
{
. . .
}
}

final class HttpRequest implements Runnable
{
. . .
}
public static void main(String argv[]) throws Exception
{
// Set the port number.
int port = 6789;

. . .
}
// Establish the listen socket.


ServerSocket listenSocket = new ServerSocket(6789);


// Process HTTP service requests in an infinite loop.
while (true) {
// Listen for a TCP connection request.



Socket connectionSocket = listenSocket.accept();
. . .
}
// Construct an object to process the HTTP request message.


HttpRequest request = new HttpRequest(connectionSocket);


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

// Start the thread.
thread.start();
final class HttpRequest implements Runnable
{
final static String CRLF = "\r\n";
Socket socket;

// Constructor
public HttpRequest(Socket socket) throws Exception
{
this.socket = socket;
}

// Implement the run() method of the Runnable interface.
public void run()
{
. . .
}

private void processRequest() throws Exception
{
. . .
}
}
// Implement the run() method of the Runnable interface.
public void run()
{
try {
processRequest();
} catch (Exception e) {
System.out.println(e);
}
}
private void processRequest() throws Exception
{
// Get a reference to the socket's input and output streams.
InputStream is = ?;
DataOutputStream os = ?;

// Set up input stream filters.
?
BufferedReader br = ?;

. . .
}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on web server HELP Or get search suggestion and latest updates.




Tagged: