wood burning stoves 2.0*
The moose likes Servlets and the fly likes JSP Forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP Forward" Watch "JSP Forward" New topic
Author

JSP Forward

Anoop Krishnan
Ranch Hand

Joined: May 03, 2001
Posts: 163
How can i forward the request from a jsp page to another jsp which may be in another ServletContext.
I think the following is Wrong
<jsp:forward page="http://anothersite/another.jsp?id=3er&index=2" />
is there Ny other solution


I just want to know is there any body call my bean's Getter and Setter methods with "Please" in front - My favorite quip from Bugzilla
Sanjay, Lalwani
Greenhorn

Joined: Jun 05, 2001
Posts: 4

Hi
I need help here
I want to have a communication between servlet and jsp im using websphere i want to send data from servlet to JSP I am facing dread full errors which has no meaning can any body help me please
Cheers
Sanjay
Originally posted by Anoop Krishnan:
How can i forward the request from a jsp page to another jsp which may be in another ServletContext.
I think the following is Wrong
<jsp:forward page="http://anothersite/another.jsp?id=3er&index=2" />
is there Ny other solution

Poornima Shetty
Greenhorn

Joined: Dec 12, 2000
Posts: 26
Hi Sanjay,In your case data from servlet to any jsp that you want can be sent as below using either the forward or include,but using include is more efficient.
getServletConfig().getServletContext().getRequestDispatcher("/package/jsp name that you want to go to").include(request,response);
and Anoop in your case instead of using jsp:forward you can call a javascript function onclick of any submit button or whatsoever
as below:
function sendToJsp()
{
location.href = "jspname.jsp?hFirst=a&hSecond=b";
}
Anoop Krishnan
Ranch Hand

Joined: May 03, 2001
Posts: 163
Thank You Purnima for your reply,
But i can not use that method because my jsp page accepts request from different pages with forward as a parameter.So it will get the attribute of jsp:forward method as a request attribute and after having some processing it will forward the request to the another page as follows
String forward=request.getParameter("forward");
<jsp:forward page='<%= forward %>' />
if forward is a page in the same servlet context it will work.but it will not work if the target is in a different context
Mallika Kumar
Ranch Hand

Joined: Feb 15, 2001
Posts: 61
How about using HttpServletResponse object and redirecting it to the destination ?
String destination = "/yourdestination.jsp";
response.sendRedirect(destination);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP Forward
 
Similar Threads
doubt in flush method
Forwarding the page after some time delay
Help please: forwarding a request in a jsp
Any JSP Timer
forwarding to jsp