File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes URGENT:Error when using Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "URGENT:Error when using "forward" method of RequestDispatcher" Watch "URGENT:Error when using "forward" method of RequestDispatcher" New topic
Author

URGENT:Error when using "forward" method of RequestDispatcher

Raj Sikka
Ranch Hand

Joined: Apr 11, 2003
Posts: 34
Hi ,
I am getting "ServletException" while using forward method of RequestDispatcher.
Can anyone suggest the solution for this.
i am using following piece of code.
It gave ServletException at "rd.forward(--)".
------------------------------------
RequestDispatcher rd =
request.getRequestDispatcher("xyz.jsp");
rd.forward(request,response);
return;
------------------------------------
what are all possible ways to get ServletException.
And what is the workaround for this problem?
Pls help.
Thanks in advance ,
Srikanth
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
A ServletException usually comes with a descriptive string, which you should find in the stack trace. Can you tell us what it is?


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Raj Sikka
Ranch Hand

Joined: Apr 11, 2003
Posts: 34
Hi ,Thanks for your prompt response.
here is the stack trace that i obtained.
---------------------------------------
javax.servlet.ServletException
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:256)
at nif.wnf.util.ErrorPage.displayErrorPage(ErrorPage.java:127)
at svm.eug.servlet.EUGControllerServlet.EUGConnectivityModified(EUGControllerServlet.java:2537)
at svm.eug.servlet.EUGControllerServlet.service(EUGControllerServlet.java:123)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:21)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at nif.wnf.filter.SessionFilter.doFilter(SessionFilter.java:88)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2501)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2204)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
there's nothing below there, giving a "root cause" ?
Is it possible that the page you forwarded to is actually generating the exception?
[ July 23, 2003: Message edited by: Ron Newman ]
Raj Sikka
Ranch Hand

Joined: Apr 11, 2003
Posts: 34
Hi,
That was the only stack trace that i got.
One more thing is ..
"xyz.jsp" is compiled successfully.
I wrote one "out.println()" statement at the first line of that jsp. i couldnt see that line also while executing.
it simply says "ServletException" and it points the line "rd.forward("xyz.jsp")".
what is the problem in forwarding to that jsp ?
pls help,
Srikanth
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Does this error still happen if you replace the contents of "xyz.jsp" by something simple, like this?
<html>
<head><title>test</title></head>
<body><p>Hello, world!</p></body>
</html>
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5370
is your xyz.jsp is in the same folder where your servlet is residing ??
with this request.getRequestDispatcher("xyz.jsp");
code, server will try to locate xyz.jsp in the directory where servlet is available.
If you have folder structure like..
webApp-->context->jsp->xyz.jsp
then you should use following code:
request.getRequestDispatcher("/jsp/xyz.jsp");
CMIW
HTH


"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: URGENT:Error when using "forward" method of RequestDispatcher
 
Similar Threads
getting servlet name from request?
forward() Method Problem
Forwarding request to same servlet
html:errors tag not working
forward method in jsp