@@ -205,6 +205,8 @@ private final class SessionRepositoryRequestWrapper extends HttpServletRequestWr
205
205
206
206
private boolean requestedSessionInvalidated ;
207
207
208
+ private boolean hasCommitedInInclude ;
209
+
208
210
private SessionRepositoryRequestWrapper (HttpServletRequest request , HttpServletResponse response ) {
209
211
super (request );
210
212
this .response = response ;
@@ -338,7 +340,7 @@ public String getRequestedSessionId() {
338
340
@ Override
339
341
public RequestDispatcher getRequestDispatcher (String path ) {
340
342
RequestDispatcher requestDispatcher = super .getRequestDispatcher (path );
341
- return new SessionCommittingRequestDispatcher (requestDispatcher );
343
+ return new SessionCommittingRequestDispatcher (requestDispatcher , this );
342
344
}
343
345
344
346
private S getRequestedSession () {
@@ -397,8 +399,11 @@ private final class SessionCommittingRequestDispatcher implements RequestDispatc
397
399
398
400
private final RequestDispatcher delegate ;
399
401
400
- SessionCommittingRequestDispatcher (RequestDispatcher delegate ) {
402
+ private final SessionRepositoryRequestWrapper wrapper ;
403
+
404
+ SessionCommittingRequestDispatcher (RequestDispatcher delegate , SessionRepositoryRequestWrapper wrapper ) {
401
405
this .delegate = delegate ;
406
+ this .wrapper = wrapper ;
402
407
}
403
408
404
409
@ Override
@@ -408,7 +413,10 @@ public void forward(ServletRequest request, ServletResponse response) throws Ser
408
413
409
414
@ Override
410
415
public void include (ServletRequest request , ServletResponse response ) throws ServletException , IOException {
411
- SessionRepositoryRequestWrapper .this .commitSession ();
416
+ if (!this .wrapper .hasCommitedInInclude ) {
417
+ SessionRepositoryRequestWrapper .this .commitSession ();
418
+ this .wrapper .hasCommitedInInclude = true ;
419
+ }
412
420
this .delegate .include (request , response );
413
421
}
414
422
0 commit comments