• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP Forward

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about using HttpServletResponse object and redirecting it to the destination ?
String destination = "/yourdestination.jsp";
response.sendRedirect(destination);
 
reply
    Bookmark Topic Watch Topic
  • New Topic