You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by li xinqian <le...@braveminds.com> on 2002/05/21 11:33:19 UTC

jsp:include a servlet and the servlet forwards to a jsp file

hello
i have a jsp:include and forward problem 
the scenario is as follows. 

i have two JSP files and one servlet files. 

In the First File say "index.jsp" i am including one servlet file say "ServletTest". and in the included servlet file i am forwarding to the other jsp file say "test.jsp" but i am getting an error javax.servlet.ServletException 

i am working on j2ee ri 1.3.1(jsp&servlet container cored tomcat )... please reply soon me really stuck 

thanks alot !! 


All files as attachments original.war 

----------------------------------------------- 

<!--content of index.jsp:--> 

<jsp:include page="/ServletTest"/> 


------------------------------------------------ 

//content of ServletTest.java: 

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*; 


/**
 * @Author heinzli
 */
public class ServletTest extends HttpServlet
{
    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException 
    {
        System.out.println("servlet");  

        

        RequestDispatcher rd = getServletContext().getRequestDispatcher("/test.jsp");
        
        rd.forward(request,response);
    }
    
   
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException 
    {
        doPost(request,response);
    }        
} 


------------------------------------------------ 

<!--content of test.jsp:--> 

<br>i m return file.<br>




heinzli