|
CSCI A348/548
|
In class we talked about the projects and then developed this:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Chat extends HttpServlet {
public void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
{
resp.setContentType("text/html");
resp.getWriter().println(
"<html><head><title>L19_S3 GET</title></head><body bgcolor=white>"
+ "<form method=POST action=/examples/servlet/Chat>Type your name here: "
+ "<input type=text name=namefield size=10> <p> then push <input "
+ " type=submit value=Proceed> (or hit Enter) </form></body></html>"
);
}
public void doPost(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
{
resp.setContentType("text/html");
resp.getWriter().println(
"<html><body bgcolor=white><h1>Hello, <font color=blue>"
+ req.getParameter("namefield")
+ "</font>!</h1>"
+ " <applet code=ChatApplet "
+ "codebase=\"http://burrowww.cs.indiana.edu:12000/chat\""
+ " width=400 height=400> "
+ " <param name=user value=\""
+ req.getParameter("namefield")
+ "\"> "
+ " </applet>"
+ " </body></html>"
);
}
}
Then we also talked about applets.
A348/A548.