/**Servlet 1 out of 2 demonstrating how to implement sessions with HTML forms with hidden fields. * Internet Programming 2 - Course * @author Martin Carlsson */ import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; import mixer.*; public class A_4_1_2 extends HttpServlet { private String htmlFileName ="A_4_1_2_2.htm"; private static String htmlFile = null; private static String servletRoot = "/content/dsv/Ip2/A_4_1_2/A_4_1_2_2"; public void init() { if(htmlFile == null) { htmlFile = Mixer.getContent(new File(getServletContext().getRealPath(servletRoot + "\\" + htmlFileName))); } } public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { Mixer m = new Mixer(htmlFile); res.setContentType("text/html"); PrintWriter out = res.getWriter(); String[] values = req.getParameterValues("name"); m.add("_name_",values[0]); out.println(m.getMix()); } }