Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling servlets

 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • 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
 
Shripad Bokil
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • 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).]
 
Karthi Bala
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • 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
 
Dmitriy Pavlyuk
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic