Posted By:
Mike_Tighe
Posted On:
Tuesday, March 7, 2006 10:27 AM
I am encountering a bizarre problem, and I'm hoping someone has an idea of what's going on. What I have is a JSP that includes another JSP, which redirects (using sendRedirect) to a servlet. For some reason, code in the servlet is getting executed BEFORE the code in the JSP that calls sendRedirect. For example, suppose the jsps/servlet are something like this JSP1: <%System.out.println("JSP1"); %> <%@ include file="JSP2" %> JSP2: <% System.out.println("JSP2"); %> <% response.sendRedirect("MyServlet"); %> MyServlet: ... public void doPost(...) { System.ou
More>>
I am encountering a bizarre problem, and I'm hoping someone has an idea of what's going on. What I have is a JSP that includes another JSP, which redirects (using sendRedirect) to a servlet. For some reason, code in the servlet is getting executed BEFORE the code in the JSP that calls sendRedirect.
For example, suppose the jsps/servlet are something like this
JSP1:
<%System.out.println("JSP1"); %>
<%@ include file="JSP2" %>
JSP2:
<% System.out.println("JSP2"); %>
<% response.sendRedirect("MyServlet"); %>
MyServlet:
...
public void doPost(...) {
System.out.println("MyServlet");
}
Now, when I navigate to JSP1 in my browser, one would think that I would see the output
JSP1
JSP2
MyServlet
on the server (tomcat). But it does not do this, it instead outputs
MyServlet
JSP1
JSP2
Which causes big problems for me. To make things even more bizarre, occasionally it executes in the correct order, when I have made no modifications!
Does anyone have any clue what could be going on here?
<<Less