Hi sorry about this kind of nooby question but i have started learning java and i am making a Chat Application, i am making it using the killer game programming in java book. But i have ran into a problem.
The Code asks me to import
import javax.servlet.*;
import javax.servlet.http.*;
but according to my IDE netbeans 6.9
Package javax.servlet.*; does not exist.
Package javax.servlet.http.*; does not exist.
These imports play a huge part in the project as you need the servlets for parts such as these
public class ChatServlet extends HttpServlet
{
private ChatGroup cg; // for storing client information
public void init() throws ServletException
{ cg = new ChatGroup(); }
public void doGet( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException
// look at the cmd parameter to decide which message the client sent
{
String command = request.getParameter("cmd");
System.out.println("Command: " + command);
if (command.equals("hi"))
processHi(request, response);
else if (command.equals("bye"))
processBye(request, response);
else if (command.equals("who"))
processWho(response);
else if (command.equals("msg"))
processMsg(request, response);
else if (command.equals("read"))
processRead(request, response);
else
System.out.println("Did not understand command: " + command);
} // end of doGet()
private void processHi(HttpServletRequest request,
HttpServletResponse response)
throws IOException
/* Message format: ChatServlet?cmd=hi&name=??
The client wants to join the chat group.
The server returns a uid cookie, or rejects the client.
*/
{
int uid = -1; // default for failure
String userName = request.getParameter("name");
if (userName != null)
uid = cg.addUser(userName); // attempt to add to group
if (uid != -1) { // the request has been accepted
Cookie c = new Cookie("uid", ""+uid);
response.addCookie(c);
}
PrintWriter output = response.getWriter();
if (uid != -1)
output.println("ok");
else
output.println("no"); // request was rejected
output.close();
} // end of processHi()
If you wanted i would put the full code of the .java file down, just ask on the post.
Thanks in advance
NSSLTD