@@ -204,6 +204,8 @@ private final class SessionRepositoryRequestWrapper extends HttpServletRequestWr
204
204
205
205
private boolean requestedSessionInvalidated ;
206
206
207
+ private boolean hasCommitedInInclude ;
208
+
207
209
private SessionRepositoryRequestWrapper (HttpServletRequest request , HttpServletResponse response ) {
208
210
super (request );
209
211
this .response = response ;
@@ -343,7 +345,7 @@ public String getRequestedSessionId() {
343
345
@ Override
344
346
public RequestDispatcher getRequestDispatcher (String path ) {
345
347
RequestDispatcher requestDispatcher = super .getRequestDispatcher (path );
346
- return new SessionCommittingRequestDispatcher (requestDispatcher );
348
+ return new SessionCommittingRequestDispatcher (requestDispatcher , this );
347
349
}
348
350
349
351
private S getRequestedSession () {
@@ -403,8 +405,11 @@ private final class SessionCommittingRequestDispatcher implements RequestDispatc
403
405
404
406
private final RequestDispatcher delegate ;
405
407
406
- SessionCommittingRequestDispatcher (RequestDispatcher delegate ) {
408
+ private final SessionRepositoryRequestWrapper wrapper ;
409
+
410
+ SessionCommittingRequestDispatcher (RequestDispatcher delegate , SessionRepositoryRequestWrapper wrapper ) {
407
411
this .delegate = delegate ;
412
+ this .wrapper = wrapper ;
408
413
}
409
414
410
415
@ Override
@@ -414,7 +419,10 @@ public void forward(ServletRequest request, ServletResponse response) throws Ser
414
419
415
420
@ Override
416
421
public void include (ServletRequest request , ServletResponse response ) throws ServletException , IOException {
417
- SessionRepositoryRequestWrapper .this .commitSession ();
422
+ if (!this .wrapper .hasCommitedInInclude ) {
423
+ SessionRepositoryRequestWrapper .this .commitSession ();
424
+ this .wrapper .hasCommitedInInclude = true ;
425
+ }
418
426
this .delegate .include (request , response );
419
427
}
420
428
0 commit comments