import java.io.IOException;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class A7 extends HttpServlet{
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws IOException,ServletException {
doPost (req,res);
}
public void doGet (HttpServletRequest req, HttpServletResponse res)
throws IOException,ServletException {
res.setContentType("text/html");
HTML html = new HTML ("Aufgabe 7","");
html.append("<h2>IM2 - Aufgabe 7: Header des Request </h>");
Enumeration headers=req.getHeaderNames();
html.table();
while (headers.hasMoreElements()){
String name=(String)headers.nextElement();
html.tr(name+": ",(String)req.getHeader(name));
}
html.tableEnd();
html.end();
res.getWriter().print(html); // print() schreibt das Ergebnis von obj.stoString
// hier: html.toString ohne Zeilenvorschub in den
//in den Stream
}
}