Posts

Showing posts from November 30, 2012

GetSession

import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class GetSession extends HttpServlet {     public void doGet(HttpServletRequest request, HttpServletResponse response)     throws IOException, ServletException     {         response.setContentType("text/html");         PrintWriter out = response.getWriter();     HttpSession hs=request.getSession();     String str1=(String)hs.getAttribute("a");     String str2=(String)hs.getAttribute("b");     out.println(str1+str2);     } }

SetSession

import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class SetSession extends HttpServlet {     public void doGet(HttpServletRequest request, HttpServletResponse response)     throws IOException, ServletException     {         response.setContentType("text/html");         PrintWriter out = response.getWriter();     HttpSession hs=request.getSession();     hs.setAttribute("a","pakistan");     hs.setAttribute("b","india");     out.println("Done");     } }