aspose file tools*
The moose likes Servlets and the fly likes How To Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How To "Forward Request" in JSP" Watch "How To "Forward Request" in JSP" New topic
Author

How To "Forward Request" in JSP

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
How do we forward request to anther JavaServer Page (filename.jsp)?
For example, we can write the following in Servlet:
if (request.getParameter("flights") != null) {
gotoPage("BookFlights.jsp", request, response);
private void gotoPage(String address,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher(address);
dispatcher.forward(request, response);
}
If we have to write the above code fragment in JSP, how are we supposed to write the code? Thank you if you could show it to me.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
<% response.sendRedirect(String); %>


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
one way to send your request through redirection is what thomas has given you and the second way is :---
<jsp: forward page= "path of the file" />

Raghav.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How To "Forward Request" in JSP