It's not a secret anymore!*
The moose likes Servlets and the fly likes forward call failed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "forward call failed" Watch "forward call failed" New topic
Author

forward call failed

Dhondiba Joshi
Ranch Hand

Joined: Jan 23, 2004
Posts: 39
In my apllication the forward of requestdispatcher is failing.
I have a code somthing like this
<code>
XXXXX.forward(X.jsp,servlet, req, resp);
</code>
intresting part is though i get "forward call failed " on server console, the user is forwarded to X.jsp without any error on browser side.
This is the logout page of my application before which i am invalidating the session. Can this cause problem ?
Anybody happened to experience such thing , please help


SCJP,SCWCD
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5

In my copy of the JavaDocs for RequestDispatcher the forward method looks like this:

so I suspect you are not showing us the real code.
Bill
Dhondiba Joshi
Ranch Hand

Joined: Jan 23, 2004
Posts: 39
Yes William

Sorry for showing my wrapper 'forward' method instead of underlying forward method. But i am finally using the same forward method which takes request and response as parameter.
The code is:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import net.eventdriven.*;
public class LogoutAction extends EpatsAction {
public void perform(
HttpServlet servlet,
HttpSession session,
HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException, EdcException {

if (session != null)
{
session.invalidate();
}
else
{
ServletConfig sc = servlet.getServletConfig();
sc.getServletContext().log("session was null already");

}
/* this call is failing */
forward("Logout.jsp",servlet, req, resp);

}
}
It goes in the if block invalidates the session and then forward call fails.
Help !
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
You still have not shown the code that is failing. We are not mindreaders.
If you see "forward call failed" on the console, it must be written by your forward code since the RequestDispatcher forward just throws an IOException.
Bill
(actually I am getting a vision.... yes... since the user is actually forwarded to the jsp, you have a logic error that comes after the forward call .... )
Dhondiba Joshi
Ranch Hand

Joined: Jan 23, 2004
Posts: 39
Hi William !
This is the underlying code that is giving the error. I know i was slow on this to reply.Please help.
The problem here is i get an error saying "forward call failed" but user is forawrded to the page without any problem. Any bod yhas gone through such situation.
<code>
ServletContext app = servlet.getServletContext();
String jspPath = app.getInitParameter("jspPath");
if (jspPath == null)
jspPath = "";
RequestDispatcher rd = req.getRequestDispatcher(jspPath + jsp);
if(rd == null) app.log("rd is null!!!" );
rd.forward(req, resp);
</code>
Dhondiba Joshi
Ranch Hand

Joined: Jan 23, 2004
Posts: 39
I made sure that 'jsppath' is correct and 'rd' is not null.
Can it be an errors in the jsp page to which call is forwarded ?
Thanks in advance
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
If this was my problem I would concentrate on finding out where the "forward call failed" message is actually coming from. In cases like this I actually just do a bulk search of all files in my source code, and if that fails, the entire set of server directories for the text.
If the message is appearing on your console it is probably being written by a System.out.print somewhere. Again, if the user is actually forwarded, you probably have a logic error after the forward call.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: forward call failed
 
Similar Threads
can Layout JSPs in tiles be extended or reused ?
document.form.action problem
HFSJ out.write() jsp:forward
Servlet Filtering doesnt work on iPlanet 6
JSP Request forwarding