Results 1 to 2 of 2
  1. #1
    gapper is offline Member
    Join Date
    Jan 2008
    Rep Power

    Default Servlet calling JSP page

    How can I call a JSP page from a Servlet. I have the required data in session variables, and want to access that data from JSP. I don't know how to redirect to JSP page. Please give sample.


  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Bali, Indonesia
    Rep Power


    You can either use the HttpServletResponse.sendRedirect() method or using HttpServletRequest.forward() method. This two method have a different behavior. The sendRedirect() will cause a browser to initiate a new request to the server, this means you have to keep your data so it will arrive on the next target page, for example you can keep the data in session scope.

    While the forward method will just forward the request to another target without asking the browser to initiate a new request, or the browser didn't know that you request is processed in another page.

Similar Threads

  1. Replies: 9
    Last Post: 01-23-2014, 07:17 PM
  2. how to load a servlet on index.jsp page...
    By sujithc34 in forum Java Servlet
    Replies: 1
    Last Post: 01-19-2008, 12:28 AM
  3. MIDLet calling Servlet
    By ravian in forum Java Servlet
    Replies: 1
    Last Post: 12-06-2007, 12:48 PM
  4. Replies: 1
    Last Post: 08-07-2007, 03:47 PM
  5. Help with Calling a method
    By Albert in forum New To Java
    Replies: 3
    Last Post: 07-10-2007, 03:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts