File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes How Can Servlet Call its self Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How Can Servlet Call its self" Watch "How Can Servlet Call its self" New topic

How Can Servlet Call its self


Joined: May 29, 2002
Posts: 2
I use MVC model with one Servlet and Many Handlers
, The Servlet forward to the specified handler which perform some business logic then forward to the JSP :
getServletContext().getRequestDispatcher( JSP_NAME ).forward( p_Request, p_Response );
Now I need to forward first to another handler(The same servlet) to perform some business and then forward to JSP , How can I do that ?

Officer - African Armed Forces
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Instead of forwarding, can you just use include? In this case you will still be within your main servlet, but you will be including the functionality of another servlet.

So much trouble in the world -- Bob Marley

Joined: May 29, 2002
Posts: 2
How Can I use include in this case ?
Kai Liu

Joined: May 29, 2002
Posts: 9
You may try the directives.
<jsp:forward page='URL' | <%= expression %> flush="true" />
like this...
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
CaptainYasser and tofranklu
Welcome to the JavaRanch! Please adjust your displayed name to meet
the <BR>JavaRanch
Naming Policy
. <BR>You can change it here.<BR><BR>Thanks!
and welcome to the JavaRanch!
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
If it's not a silly question, why do you think you need to "forward" to the same same servlet at all? Why not just call a method to do your "business"?

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
I agree. Here's the link:
subject: How Can Servlet Call its self
It's not a secret anymore!