• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

ways to include a servlet from a JSP

 
Ranch Hand
Posts: 635
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know how to call a servlet froma JSP using a form. But what I want to do is call a servlet to do some processing from a servlet. I think there is a way round it using ServletDispatcher().include which will call the servlet carry out the process and then return to the calling page.

Problem is I cant find any example code.

Thanks for any help Tony
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Example in Sun's tutorial. found by Google search for "servlet tutorial requestdispatcher"
Bill
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RequestDispatcher rd = myServletContext.getRequestDispatcher("/contextRelativePath");
rd.include(request, response);

You can also use a relative path if you get the RequestDispatcher from the ServletRequest object.
 
Tony Evans
Ranch Hand
Posts: 635
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tony
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use also use a JSP standard Action:

<jsp:include page="/servletUrlMapping" flush="true">
<jsp aram name="paramName" value="paramValue" />
</jsp:include>
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic