Samuele Brignoli wrote:
>
> I hope that someone good with JSP and Servlet can help me ...
>
> I'm triying to send an error message to a jsp page called error.jsp located
> in c:\Apache_Group\Apache\htdocs\folder1\
> from a servlet MultitelPay.jsp located in the same directory,
> c:\Apache_Group\Apache\htdocs\folder1\.
> In my servlet I've tried this code :
>
>                 try
>                 {
>
> getServletConfig().getServletContext().getRequestDispatcher("error.jsp?error
> =fatal error").forward                  (request,response);
>
>                 } catch (Exception ex) {
>                     ex.printStackTrace ();
>                 }

The uri path argument to getRequestDispatcher must start with a slash ("/")
and is interpreted relative to the context's base URI. So if you use the default
context (base URI = "/") and it's docbase is "c:\Apache_Group\Apache\htdocs",
you must use

  getRequestDispatcher("/folder1/error.jsp?error=fatal+error")

Also note that the parameter value must be URL encoded (space replaced with
plus sign) and that there's no guarantee that the query string parameters
are passed on to the target in a Servlet 2.1 container (it's added to the
spec in Servlet 2.2). If you're using a 2.1 container you may want to look
at using request attributes to pass info to the target instead (see the 2.1
or 2.2 spec for details).

The reason you get an "internal error" should be clear if you look in the
servlet container log file. Most likely you will find a NullPointerException,
since getRD returns null in your example and trying to call forward() on
null doesn't work.

--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to