• 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

Can a servlet be embedded in another servlet?

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.
Can a servlet be embedded in another servlet? If so, how?
CHAD
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chad,
I'm interpreting your question as:
"Can a servlet be defined as an instance member of another servlet?"
I haven't tried it (have you?), but I imagine that there shouldn't be any problem doing that.
I assume you have some problem you are trying to solve and you think this "embedding servlets" thing is the way to go. Frankly, I can't think of a situation where you would need to do this (and that's why I've never tried it), so perhaps you could explain about the problem you are trying to solve -- because there's probably a better way to solve it -- rather than asking if your proposed solution is feasible.
Hope this helps you.
Good Luck,
Avi.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you mean 'can the output of one servlet be included in the output of another servlet?' then the answer is yes. Like JSPs, your servlet can do a 'request dispatch include' to include the output of another servlet. Check the javadoc for ServletContext.getRequestDispatcher().
Paul
 
chad stevens
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Avi and Paul, thanks for your answers. This question was an interview question that I could not answer, another was can a servlet be embedded in JSP pages? I haven't worked with these items I know as far as what Paul did describe.
Thanks for the responses.
 
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The correct answer is
"Define what you mean by 'embedded' -- do you mean the result content, or the servlet itself?"
Sounds like a pointy-hair question rather than a technical one, although perhaps he was trying to avoid using the word "include" to avoid giving a hint.
 
chad stevens
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello David, he probably did mean include.. can you do this? Include a servlet in another?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic