-1

The problem is: I have a page1.jsp which is submitted and forwarded to page2.jsp. The problem is that the forwarded output should be only the content in page2.jsp, instead of that is showing me content from page1.jsp and immediately the content from page2.jsp

I'm using requestDispatcher.forward(String) but i don know why is this happening

PS: I'm using JE 1.4

MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125
Pigritia
  • 311
  • 3
  • 10

1 Answers1

1

Well it seems you have got the method signature incorrect . As per the javaee 1.4 API:

public void forward(ServletRequest request,ServletResponse response)
         throws ServletException,
                java.io.IOException

Hence your code should be :

RequestDispatcher dispatcher = request.getRequestDispatcher("page2.jsp);
dispatcher.forward( request, response );

Better , you can use the <jsp:forward> standard action.

The JSP that contains the action stops processing, clears its buffer, and forwards the request to the target resource. Note that the calling JSP should not write anything to the response prior to the action.

Suggested Reading:

How to avoid Java Code in JSP-Files?

Community
  • 1
  • 1
AllTooSir
  • 48,828
  • 16
  • 130
  • 164