You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2001/06/13 23:26:33 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/bean IncludeTag.java
craigmcc 01/06/13 14:26:33
Modified: src/share/org/apache/struts/taglib/bean Tag:
STRUTS_1_0_BRANCH IncludeTag.java
Log:
Pass the session ID on to a resource called by <bean:include>, even if we
are using cookies for session management ourselves. Previously, this
worked only if URL rewriting was being used.
PR: Bugzilla #2125
Submitted by: Andreas Jost <an...@id.ethz.ch>
Revision Changes Path
No revision
No revision
1.15.2.1 +16 -2 jakarta-struts/src/share/org/apache/struts/taglib/bean/IncludeTag.java
Index: IncludeTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/IncludeTag.java,v
retrieving revision 1.15
retrieving revision 1.15.2.1
diff -u -r1.15 -r1.15.2.1
--- IncludeTag.java 2001/05/14 17:54:56 1.15
+++ IncludeTag.java 2001/06/13 21:26:29 1.15.2.1
@@ -1,5 +1,5 @@
/*
- * $Id: IncludeTag.java,v 1.15 2001/05/14 17:54:56 craigmcc Exp $
+ * $Id: IncludeTag.java,v 1.15.2.1 2001/06/13 21:26:29 craigmcc Exp $
* ====================================================================
*
* The Apache Software License, Version 1.1
@@ -63,6 +63,7 @@
import java.io.BufferedInputStream;
import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@@ -92,7 +93,7 @@
* wrapped response passed to RequestDispatcher.include().
*
* @author Craig R. McClanahan
- * @version $Revision: 1.15 $ $Date: 2001/05/14 17:54:56 $
+ * @version $Revision: 1.15.2.1 $ $Date: 2001/06/13 21:26:29 $
*/
public class IncludeTag extends TagSupport {
@@ -246,10 +247,23 @@
URLConnection conn = null;
try {
+ // Set up the basic connection
conn = url.openConnection();
conn.setAllowUserInteraction(false);
conn.setDoInput(true);
conn.setDoOutput(false);
+ // Add a session id cookie if appropriate
+ HttpServletRequest request =
+ (HttpServletRequest) pageContext.getRequest();
+ if ((conn instanceof HttpURLConnection) &&
+ urlString.startsWith(request.getContextPath()) &&
+ (request.getRequestedSessionId() != null) &&
+ request.isRequestedSessionIdFromCookie()) {
+ StringBuffer sb = new StringBuffer("JSESSIONID=");
+ sb.append(request.getRequestedSessionId());
+ conn.setRequestProperty("Cookie", sb.toString());
+ }
+ // Connect to the requested resource
conn.connect();
} catch (Exception e) {
RequestUtils.saveException(pageContext, e);