• 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

Calling servlets

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a servlet in one application "A" and i want to call another servlet in an application "B" from the first servlet. How do i do this.
if possible pl tell me the same in case of EJBs too as to how to call an EJB which is existing in another application

Thanx in advance
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Regarding calling the servlet...
If your servlet 'A' has a html code embeded in out.println("....")...then you can specify the servlet "b" in the action part of the form...i.e....
<form method = get or post action ="Your servlet path here">
</form>
otherwise....
you can use sendRedirect(servlet path here)...to call servlet"b"
In case of EJB you can call another EJB by specifying the correct JNDI name in lookup for the second EJB.
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Shripad,
I think U have overlooked the question.Am asking how to call a servlet which is in web application "B" from a servlet which is in application "A"
and How do i call an EJB which is in application "B" from an EJB which is application "A"
Thanx
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
You could use ServletContext to link call the servlet.
With an EJB, the first EJB must communicate to the second, as an EJB client would. Get the reference of the Home Object and then access it.
Suneel
[This message has been edited by Suneel Setlur (edited January 31, 2001).]
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi suneel,
I tried the same with this code.
getServletConfig().getServletContext().getRequestDispatcher("/servlet/ViewMiniPoll").forward(req,res);
But I could succeed it calling the servlet ViewMiniPoll which is different in Web application.I am using JRun 3.0
Thanks in advance
Karthi
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is so easy to call servlet and receive it's output stream (if necessary). See it in the questions of the week in java.sun.com
http://developer.java.sun.com/developer/qow/archive/140/index.jsp
 
The City calls upon her steadfast protectors. Now for a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic