Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Forward

 
Anoop Krishnan
Ranch Hand
Posts: 163
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Sanjay, Lalwani
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 163
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic