Search code examples
javajspjsfxhtmlfacelets

How can we create request, response cycle with JSP pages?


While developing JSP pages, we can run a Java code in server side, while JSP page is active in the client side... How to create request and response cycle between Java Code(at the server side) and JSP page(at the client side)... What is the difference between JSP and JSF technology for this kind of dynamic web pages? And which one is better JSF or JSP?


Solution

  • You can use RequestDispatcher Method In Server side create test.java you can write

    ServletContext context= getServletContext();
    RequestDispatcher rd= context.getRequestDispatcher("/LoggedIn");
    rd.forward(request, response);// used to forward data 
    

    if you want to include data use

    rd.include(request,response);// used to include data