What is res setContentType text simply

Applet servlet communication

Example:
/ * * Applet * / / ** * This method sends a Surf2000 object to the Surf2000Server. * Waits for the answer and then shows the traffic of the answer object * in the tree and in the table. * / Public void start () {try {Surf2000 s = new Surf2000 (Utils.getSessionId (this), 1); Object obj = Utils.sendAndReceiveObject (s, "Surf2000Server", this); if (obj instanceof Surf2000) {Surf2000 s2000 = (Surf2000) obj; / * The display is now created from the data of the Surf2000 object * /} else if (obj instanceof Exception) {Utils.alert ("Servlet said:", this); Utils.showException ((Exception) obj, this); }} catch (Exception e) {Utils.showException (e, this); }} / * * Servlet * / / ** * This method reads an object from the HTTP request. You are expecting a * Surf2000 object (@see comm.Surf2000). The method reads the session ID * from the object and authorizes itself with the login server, which must run in the same * servlet environment. Then a file with the name customer number.obj * is read from the objects directory. This is interpreted as a Surf2000 object * and sent to the client. * / public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {ObjectInputStream objin = new ObjectInputStream (req.getInputStream ()); String sessionId = null; try {Surf2000 s2000 = (Surf2000) objin.readObject (); sessionId = s2000.getSessionId (); customerNr = ((LoginServer) getServletContext (). getServlet ("LoginServer")). getKundenNr (sessionId); local = ((LoginServer) getServletContext (). getServlet ("LoginServer")). getLocale (sessionId); symbols = new DecimalFormatSymbols (local); String newestFile; int [] currentMonth = new int [2]; Vector months = new Vector (); int [] my = s2000.getCurrentMonth (); newestFile = customerNr + "-" + my [0] + "_" + my [1] + ".obj"; Surf2000 data; if (! cache.containsKey (newestFile)) {FileInputStream fis = new FileInputStream (getServletContext (). getRealPath (".") + "/ objects /" + newestFile); ObjectInputStream in = new ObjectInputStream (fis); System.err.println ("reading data ..." + (new SimpleDateFormat ("hh: mm: ss")). Format (new Date ())); data = (Surf2000) in.readObject (); cache.put (newestFile, data); in.close (); } else {data = (Surf2000) cache.get (newestFile); } ObjectOutputStream out = new ObjectOutputStream (res.getOutputStream ()); out.writeObject (data); out.flush (); out.close (); } catch (Exception e) {ObjectOutputStream out = new ObjectOutputStream (res.getOutputStream ()); out.writeObject (e); out.flush (); out.close (); }}