import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public class getCookieValue extends HttpServlet { //Initialize global variables public void init(ServletConfig config) throws ServletException { super.init(config); } //Process the HTTP Get request public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); String result; PrintWriter out = response.getWriter(); Cookie[] cookies = request.getCookies(); String msgId = new String("failure"); String fileName = new String("failure"); try{ if(cookies != null){ for(int i = 0 ; i < cookies.length ; i++){ if(cookies[i].getName().equals("MDMFileUploadComplete")){ msgId = cookies[i].getValue(); } if(cookies[i].getName().equals("MDMFileUploadName")){ fileName = cookies[i].getValue(); } } } result = msgId + "*" + fileName; out.println(result); } catch(Exception ex){ ex.printStackTrace(); } finally{ out.close(); } } //Get Servlet information public String getServletInfo() { return "getCookieValue Information"; } }