How do i invoke a JSP from servlet.

Discussions

EJB design: How do i invoke a JSP from servlet.

  1. How do i invoke a JSP from servlet. (4 messages)

       Hello, this is Aravind and i hope some one will answer to my query: How do i invoke a JSP/Servlet from a JSP/Servelt. I've already used method - URL rewriting (an inefficient one). When i use a request dispatcher, i cannot send extra parameters to the new JSP/Servelt. A Req.dispatcher only allows req, res objects to be sent. My query is, how do i send extra information (new key-value parameters pairs) to the new JSP/Servlet.

    Threaded Messages (4)

  2. Hi ,
      U can use include or forward methods to pass ur request from servlet to JSP which includes ur parameters also.

    Bye ,
    Ashok.
  3. How do i invoke a JSP from servlet.[ Go to top ]

    In HttpRequest there is a method call setAttribute which take the key/value pair and using that you can pass any object servlet to jsp and vice versa
    All the best
  4. Hi,

    To invoke another JSP/Servlet from current JSP/Servlet,
    1)use in JSP

    <jsp:forward page="path">
      <jsp:param name="paramName" value="paramValu" />
    ......

    </jsp:forward>

    2) in servlets
    use HttpServletResponse.sendRedirect(String URL)

    Cheers,
    Kailash

  5. How do i invoke a JSP from servlet.[ Go to top ]

    I think best way is:

    getServletContext().getRequestDispatcher(URL).forward(request, response);