wood burning stoves 2.0*
The moose likes Servlets and the fly likes Problem in call to RequestDispatcher.include() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem in call to RequestDispatcher.include() method" Watch "Problem in call to RequestDispatcher.include() method" New topic
Author

Problem in call to RequestDispatcher.include() method

Mandar Velankar
Ranch Hand

Joined: Jul 31, 2006
Posts: 32
Can any one solve the following error asap.

When I obtained RequestDispatcher object with following code I get following exception

type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.IllegalArgumentException: Path does not start with a "/" character
com.Production.sdc.servStyleSample.service(servStyleSample.java:352)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.


Code written :

ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("/exists.jsp?formnm=create_stylesample.jsp&chksts=Exists"); // this line generate error
rd.include(req, res);

Thanks & Regards,

Mandar Velankar
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Was the forward slash there initially or did you go back and add it?
If you went back and added, are you sure the class was recompiled?
If so, are you sure the recompiled class was loaded?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Mandar Velankar
Ranch Hand

Joined: Jul 31, 2006
Posts: 32
Hi Ben
Thanks for reply.

"/" was included right from beginning , as per language requirement "/" must
be included to obtained relative path while getting RequestDispatcher object.Earlier I am not getting such kind of error , can any one find out more. Servlet is recompiled and loaded through Tomcat Manager , reload option available .Also where can I find out context path set for application in NetBeans IDE 3.6 and Tomcat environment.

Thanks & regards

Mandar Velankar
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Tomcat doesn't recompile servlets.
The reloadable attribute of the <Context .. /> entry will reload the app if a compiled class file is update but you need to compile it yourself.


The HttpServletRequest object has a getContextPath method.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem in call to RequestDispatcher.include() method
 
Similar Threads
HttpServletResponse.sendError
error page doubt
ResultSet from Servlet to JSP
SCWCD Objectives
Forward from java class