Advertisement
Guest User

aaaaaa

a guest
Nov 26th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.26 KB | None | 0 0
  1. package com;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6. import java.util.*;
  7.  
  8. import mixer.*;
  9.  
  10. import javax.servlet.ServletException;
  11. import javax.servlet.annotation.WebServlet;
  12. import javax.servlet.http.HttpServlet;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15.  
  16. import mixer.Mixer;
  17.  
  18. /**
  19.  * Servlet implementation class Ass32
  20.  */
  21. @WebServlet("/Ass32")
  22. public class Ass32 extends HttpServlet {
  23.     private static final long serialVersionUID = 1L;
  24.     private static String htmlTemplate = null;
  25.  
  26.    
  27.     public void init() throws ServletException {
  28.         if (htmlTemplate == null) {
  29.             try {
  30.                 htmlTemplate = Mixer.getContent(new File(getServletContext().getRealPath("/index.html")));
  31.             } catch (NullPointerException e) {
  32.                 e.printStackTrace();
  33.             }
  34.  
  35.         }
  36.     }
  37.        
  38.     public Ass32() {
  39.         super();
  40.         // TODO Auto-generated constructor stub
  41.     }
  42.  
  43.     /**
  44.      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
  45.      */
  46.     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  47.        
  48.         response.setContentType("text/html");
  49.         PrintWriter out = response.getWriter();
  50.         String jsp = Mixer.getContent(new File(getServletContext().getRealPath("/index.html")));
  51.         Mixer m = new Mixer(jsp);
  52.        
  53.         m.add("===name===", "Richmond");
  54.        
  55.         Map map = System.getenv();
  56.         String p1 = null;
  57.         String p2 = null;
  58.         String p3 = null;
  59.         String p4 = null;
  60.  
  61.         Set keys = map.keySet();
  62.         Iterator iterator = keys.iterator();
  63.         while (iterator.hasNext()) {
  64.           String key = (String) iterator.next();
  65.           String value = (String) map.get(key);
  66.           p1 = ("==="+key+"===");
  67.           p2 = ("==="+value+"===");
  68.           p3 = ("===key===");
  69.           p4 = ("===value===");
  70.  
  71.           m.add("<!--===xxx===-->",p3,p1);
  72.           m.add("<!--===xxx===-->",p4, p2);
  73.  
  74.         }
  75.        
  76.         String str = m.getMix();
  77.         out.println(str);
  78.     }
  79.  
  80.     /**
  81.      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
  82.      */
  83.     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  84.         // TODO Auto-generated method stub
  85.     }
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement