This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Servlet JSP Communication
Posted by Ashok on December 06, 2000 at 4:11 AM
Hi all, I would really appreciate if anybody can help me out on this one. I am using the following Servlet Code and a JSP file. The Servlet uses the RequestDispatcher.forward method to send a value to the JSP. I get the following error: *** The servlet named UpdateJSPTest at the requested URL http://65.2.232.35:8080/servlet/UpdateJSPTest reported this exception: Can not forward to servlet file : OutputStream or writer has been obtained. Please report this to the administrator of the web server. *** It also reports an IllegalStateException and points to the line in the Servlet code which is: rd.forward(req, res); The JSP file runs perfectly OK when I call it from the location bar on the browser(except that null is returned). I am using JavaWebServer2.0. I fiddled around with java.policy and a few other things. Nothing seems to work. I think it is a very trivial problem which i am not able to figure out. HELP!!!!!!!! Servet Code: *************************************** public class UpdateJSPTest extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String message = "This is a test"; req.setAttribute("message", message); PrintWriter out = res.getWriter(); RequestDispatcher rd = getServletContext().getRequestDispatcher("http://65.2.232.35:8080/index.html"); rd.forward(req,res); } } ******************************************* JSP CODE:(note that < and > replaced with *) *html* *head* */head* *body* *h1**/h1* *servlet code=UpdateJSPTest**/servlet* *% String message = (String) request.getAttribute("message"); out.print("message: *b*" + message + "*/b*"); %* *p* *ul* *% for (int i = 0; i * 5; i++) { out.println ("*li*" + i); } %* */ul* */body* */html* *****************************************
Replies:
|