Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Call Servlet from Servlet - not response.sendRedirect()  RSS feed

 
Lisa Modglin
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Servlet needs to call another Servlet, passing a key to that second Servlet. The second Servlet will return a userid as its response. I do not want to pass control to that second Servlet. Can I create a connection to that second Servlet and read the response into a variable?

I don't know what this is called so I don't know what to search on.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66186
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you could check out the URL and URLConnection classes, but it sounds like refactoring the common processing out of the second servlet so that it can be performed by both servlets makes more sense.
 
Lisa Modglin
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The URLConnection class did the trick. Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!