Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to call servlet from servlet

 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

how to call servlet from servlet as if we invoke it from browser.

what I want to do is like this:

ServletA
ServletB

each servlet is independent and generates XML element (JDOM object btw)

NewServlet:
Call ServletA, cache its XML into Jdom element
Call ServletB, add its XML into Jdom element

thanks all
tony
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tony,
I think you can try using getNamedDispatcher in ServletContext.

Correct me if I am wrong..
Hope this help...

daniel
 
Vijayendra V Rao
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use redirect. Do whatever processing that you need to do in your first servlet and then you can redirect the control to your second servlet (by specifying the URL) and then complete the remaining processing.

Go through the Servlet Response API. I think the API should help.
 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply.
but I don't think redirect will work because I dont want to move to other servlets, just want to call them.

I know we should encapsulate the business logic into bean but it is a huge application and hard to change.

thanks
tony
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic