Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Forward giving error  RSS feed

 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;
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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
* 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.
 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please specify what the problem is. Or rather put the stack trace.
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the html file in the same folder .I dont think so..so 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
getServletContext().getRequestDispatcher("../html/filename.html");
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!