Since I am a relative newbie to Java and JSP I will have to bow to your
superior knowledge. However the problem did turn out to be a simple matter
of correct paths. Tomcat ( I have discovered) expects the path to be
relative to (but not including) the server root. Having entered this,
everything worked ok since the RequestDispatch object could be correctly
instantiated.

As regards not using getWriter() and forward(request, response) together
that was only there to alert me that  the page had blown up because the
RequestWriter failed to work and it does not seem to have been a problem in
this case. Happily all is now in order. Thanks for your help.

Regards,
Eoin
----- Original Message -----
From: Majid Khojastehpour
Sent: Saturday, August 12, 2000 1:53 PM
Subject: Re: Tomcat 3.1 Calling a JSP from a servlet


Hi,

your code is wrong.
You can not use getWriter() and forward(request, response) together. if u
call getWriter() and after that call forward u will get
IllegalStateException. see JSP 1.1 specification.

Majid

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Eoin Shalloo
Sent: Friday, August 11, 2000 4:21 PM
To: [EMAIL PROTECTED]
Subject: Tomcat 3.1 Calling a JSP from a servlet


Hi,

I have a simple but irritating to solve problem.

I have a JSP which calls a servlet which in turn calls another JSP page. I
am using code from "Core servlets and JavaServer pages" to do this (Listing
15.3).

  private void gotoPage(String address,
                        HttpServletRequest request,
                        HttpServletResponse response)
      throws ServletException, IOException {
    RequestDispatcher dispatcher =
      getServletContext().getRequestDispatcher(address);
    PrintWriter out = response.getWriter();
    if (dispatcher!= null){
      out.println("dispatcher not null");
    }
    else{
      out.println("dispatcher is null");
    }
    dispatcher.forward(request, response);
  }


I think the problem is that I need to know the relative path from the
servlet location to the jsp page location in order to 'tell' the servlet
where to look for it. This I seem to be failing to do as the page always
reads dispatcher is null suggesting that the
getServletContext().getRequestDispatcher(address) is failing.

Can any Tomcat users out there assist?

Many thanks in advance.

Eoin.
~
"Ní hé lá na gaoithe lá na scolb"
T: +353 1 6710692
F: +353 1 6710863

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to