////The first chunk of code here will use 1 SINGLE Class file, one doGet and onePost////the GOAL here was to pass the VARIABLE "theOne" via an HttpSession, and it works! ////The 2nd chunk of code GOAL is to be able to use 2 SEPERATE Class files, which I do not understand//// if it is possible or not, it seems like it should be, but at the same time seems like scope problem...//// have tried for a couple of hours/searching and do not understand what to do here//// i do know how to do this same type of thing easily by having Servlet 1 write variable to database, then have////Servlet 2 retrieve it, just would like to know if possible with Sessions, and what must do//////////////////////////////////////////////////////////////////// START FIRST CHUNK ////////////////////////////////////////////////////////////////////////// START FIRST CHUNK //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////public class SessionVar extends HttpServlet { public String theOne = "421"; public String whatever = "whatE";;protected void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { HttpSession session = request.getSession( true ); request.getSession().setAttribute(whatever,theOne);//the next chunk of code would reload the servlet with the doGet method below, which willin turn "getAttribute" out.println( "<p><a href = \"SessionVar\">" + "Click here to watch the Session magic ...BWAH </a></p>" );************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************protected void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { HttpSession session = request.getSession( false );// get names of session object's values String varGet = (String)request.getSession().getAttribute(whatever);//this line will 100% successfully be print to the screen....this is using 1 SINGLE Class file, one doGet and onePost out.println( "Here is varGet: " + varGet + "</p>");//////////////////////////////////////////////////////////////////// END FIRST CHUNK ////////////////////////////////////////////////////////////////////////// END FIRST CHUNK ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// START 2nd CHUNK ////////////////////////////////////////////////////////////////////////// START 2nd CHUNK //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*******************************************************************************Start Class 1*************************Start Class 1******************************************************public class SessionVar extends HttpServlet { public String theOne = "421"; public String whatever = "whatE";;protected void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { HttpSession session = request.getSession( true ); request.getSession().setAttribute(whatever,theOne);//the next chunk of code would go to the 2nd SERVLET "Random_Verify_It"//where it would use "getAttribute" out.println( "<p><a href = \"Random_Verify_It\">" + "Click here to watch the Session magic ...BWAH </a></p>" );*******************************************************************************Start Class 2*************************Start Class 2******************************************************//THE PROBLEM THE PROBLEM THE PROBLEM THE PROBLEM//THE PROBLEM THE PROBLEM THE PROBLEM THE PROBLEM//is that the variable "whatever" cannot be found, because it is created back//inside of SERVLET 1, above//This makes sense to mean in terms of "out of scope" - it seems impossible, but//at the same time the concept of HttpSession/Sessions make me think there is a way to do this?public class Random_Verify_It extends HttpServlet { // process "get" request from client protected void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { //HttpSession session = request.getSession( false ); // String strMagicGet = (String)request.getSession().getAttribute(strMagic); // request.getSession().setAttribute(whatever,theOne); String varGet2 = (String)request.getSession().getAttribute(whatever);//////////////////////////////////////////////////////////////////// END 2nd CHUNK ////////////////////////////////////////////////////////////////////////// END 2nd CHUNK //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////