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

Servlet and JSP interaction

 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In which all ways a servlet can call a JSP page, and vice versa? I know one way. My interviewer said there are at least 4 ways (each) of doing this. Can someone elaborate the 4 ways?
Also, what sort of interview questions can I expect on Servlets/JSP?
TIA,
- Manish
 
Dominic Paquette
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Calling a jsp from a servlet:
1:
HttpServletResponse.sendRedirect
2:
RequestDispatcher.forward
3:
RequestDispacther.include
4:
maybee more?
Calling a servlet from a jsp:
the 3 ways mentioned above(since a jsp gets translated to a servlet) plus
<jsp:include page="/myServlet">
<jsp:forward page="/myServlet">
<%@ include file="/myServlet" %>
Those are the ways I know, (I haven't tried out the code thought) Hope this helps
Dominic
 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dominic!
I has been quite some time since I used Servlets, I guess I need to refresh my knowledge ASAP..
- Manish
 
chad stevens
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Manish!
I have read it on the Sun site last night but I wasn't sure that was the answer so I was waiting for a post!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic