This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes Forward giving error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "Forward giving error" Watch "Forward giving error" New topic

Forward giving error

clyde melly
Ranch Hand

Joined: Sep 04, 2003
Posts: 152
import javax.servlet.*;
import javax.servlet.http.*;
public class ForwardServlet extends HttpServlet
public void doGet (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
String message = "This is a test";
RequestDispatcher rd =req.getRequestDispatcher("login.html");
rd.forward(req, res);

Requestdispatcher gives problem?kindly help
Anand Loganathan

Joined: Sep 13, 2003
Posts: 12
* The pathname specified may be relative, although it cannot extend outside the current servlet context.
find out where your html file is existing
* If the path begins with a "/" it is interpreted as relative to the current context root.
give the pathname is ("/*.html") // relative path from servlet root.
* This method returns null if the servlet container cannot return a RequestDispatcher.
Make sure that your file is existing in the specified path.
Kaustubh Patil
Ranch Hand

Joined: Aug 13, 2001
Posts: 164
Could you please specify what the problem is. Or rather put the stack trace.

Kaustubh. Mumbai, India.
Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182
Is the html file in the same folder .I dont think just specify the path according to the folder.
for ex.
if the servlet file is in classes folder and the html is in html folder.
then write the code as

Have you checked out Aspose?
subject: Forward giving error
It's not a secret anymore!