You have a mechanism called "forwarding", with which you can pass control from one resource (servlet/jsp) to another resource (servlet/jsp). You do this using a RequestDispatcher, which you can get from the HttpServletRequest object. If for example you want to forward to "index.jsp" which is in the root of your web application, you would do this in your servlet:
RequestDispatcher rd = request.getRequestDispatcher("/index.jsp");
rd.forward(request, response);
return;
(watch the return statement, you must manually return after a forward, or else the servlet will continue executing!). A forward will NOT create a new request, the same request is passed to the new resource (to create a new request, use a redirect in stead, also done with the RequestDispatcher).
To pass objects between the two resources when doing a forward, use request.setAttribute(), request.getAttribute() and jsp:useBean.
so i've to do this with sessions and everything i want to pass to: for example my application is a servlet based, from a servlet to a JSP so i have to do it with:
RequestDispatcher rd = request.getRequestDispatcher("/servletToJsp.jsp");
rd.forward(request, response);
return;
if its from a JSP to a servlet it is the same way?, if i want to pass the session from one to another and viceversa how do i do that?,and its possible to import into a JSP a class that isn't a bean? because like i wrote here my appplication is a servlet-based but i want to insert new JSPs so thanks for your help and if its possible to respond my questions.