/* *Kristian Laukkonen *Uppgift 1.2.2 */ import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.Enumeration; public class A122 extends HttpServlet { private static String htmlTemplate = null; //länkar html-dokumentet till Mixern public void init() { if (htmlTemplate == null) { htmlTemplate = Mixer.getContent(new File(getServletContext().getRealPath("A122.html"))); } } //stoppar värdet i Mixern "text/html" public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { Mixer mix = new Mixer(htmlTemplate); HttpSession session = req.getSession(true); res.setContentType("text/html"); PrintWriter pW = res.getWriter(); ServletContext sC = getServletContext(); //stoppar in värdet i mixern mix.add("","---name---", "Servlet Name"); //server info mix.add("","---value---", getServletName()); mix.add("","---name---", "Servlet Path"); mix.add("","---value---", req.getServletPath()); mix.add("","---name---", "Server Name"); mix.add("","---value---", req.getServerName()); mix.add("","---name---", "Server Port"); mix.add("","---value---", Integer.toString(req.getServerPort())); mix.add("","---name---", "Server Info"); mix.add("","---value---", sC.getServerInfo()); mix.add("","---name---", "SERVER ATTRIBUTES"); mix.add("","---value---", ""); mix.add("","---name---", "RUNTIME VERSIONS"); //RUNTIME VERSIONS mix.add("","---value---", ""); mix.add("","---name---", "Minor webserver version"); mix.add("","---name---", "JDK version"); mix.add("","---value---", System.getProperty("java.version")); mix.add("","---name---", "Remote Host"); mix.add("","---value---", req.getRemoteHost()); mix.add("","---name---", "Remote Adress"); mix.add("","---value---", req.getRemoteAddr()); mix.add("","---name---", "Request Protocol"); mix.add("","---value---", req.getProtocol()); mix.add("","---name---", "Remote User"); mix.add("","---value---", req.getRemoteUser()); mix.add("","---name---","SESSION INFORMATION"); //SESSION INFO mix.add("","---value---", ""); mix.add("","---name---", "Requested Session ID"); mix.add("","---value---", req.getRequestedSessionId()); mix.add("","---name---", "Request Method"); mix.add("","---value---", req.getMethod()); // skriver ut och stänger av mixern pW.println(mix.getMix()); pW.close(); } }