To preprocess data, use Servlet's doGet() method.
Data data = dataDAO.load();
request.setAttribute("data", data);
request.getRequestDispatcher("page.jsp").forward(request, response);
To access data in JSP, use EL (which searches in page, request, session and application scope in this order for attributes with the given name).
<br>Plain object: ${data}
<br>A property: ${data.property}
<br>Explicitly search in request scope: ${requestScope.data}
To send data from JSP to servlet you normally use request parameters which are controlled by the client side. Most commonly HTML forms are been used for this. Alternatively you can also use Javascript to fire an asynchronous request to the server side.
Anything in a certain scope is accessible for anything which lives in the same scope. The request scope lives from the moment that the client initiated a request (by clicking a link, button, bookmark or by entering the URL in address bar) until the moment that the server has sent the last bit of the response. You normally store request specific data in there like form data. The session scope lives from the moment that the client requested the webpage for the first time and the HttpSession hasn't been created yet until the time that the HttpSession times out after not been used for a time which is configureable as in web.xml, or when the code explicitly times out it using HttpSession#invalidate()
. You normally store user-specific data in there, like the logged in user and user preferences and so on. The application scope lives from the moment that the server starts up until the moment that the server shutdowns (or restarts). You normally store applicationwide data in there, like static dropdown data, the DAO factory, webapp configuration data, etcetera.
The request is accessible by HttpServletRequest argument in Servlet class.
The session is accessible by HttpServletRequest#getSession() in Servlet class.
The application is accessible by inherited getServletContext() method in Servlet class.
They all have a get/setAttribute() method.
To learn more about JSP/Servlet/EL I can recommend you the Sun Java EE 5 tutorial part II chapters 1-8.
Good luck.