• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Connect Two Servlet

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to communicate between 2 Servlet.any way through which I can do it.

For e.g.Suppose I have a Html form and I extract some data from this form with the help of the sevlet(I am able to do it).All I want ot know out of this data I want to pass some of the data to another servlet.
So I want to know whether this is possible.
If possible how?

In short i want to know how two servlets can communicate
 
Sheriff
Posts: 67597
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why?

Answering that question may help answer the question.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes indeed you can pass form parameters from one servlet to the other using RequestDispatcher.
One of the below out of 1/2/3 can be used
1)RequestDispatcher view=request.getRequestDispatcher("jsp_name.jsp");
2)RequestDispatcher view=request.getRequestDispatcher("/jsp_name.jsp");
3)RequestDispatcher view=getServletContext().getRequestDispatcher("/jsp_name.jsp");
and then
view.forward(request,response);
This forwards request and response to the other element of the web-app.
You can also use application scoped dynamic attributes to store form data in them so that every resource in the web-app can use it..

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes indeed you can pass form parameters from one servlet to the other using RequestDispatcher.
One of the below out of 1/2/3 can be used
1)RequestDispatcher view=request.getRequestDispatcher("jsp_name.jsp");
2)RequestDispatcher view=request.getRequestDispatcher("/jsp_name.jsp");
3)RequestDispatcher view=getServletContext().getRequestDispatcher("/jsp_name.jsp");
and then
view.forward(request,response);
This forwards request and response to the other element of the web-app.
You can also use application scoped dynamic attributes to store form data in them so that every resource in the web-app can use it..


while you do forward add request parameters.

or you can set session attribute

Or else you can go for context attribute

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic