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/05/09 06:42:10 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/bean IncludeTag.java

craigmcc    01/05/08 21:42:10

  Modified:    src/share/org/apache/struts/taglib/bean IncludeTag.java
  Log:
  Use the containers existing facilities to encode the session ID into the
  URL that is used for the URL connection created in <bean:include>.
  
  PR: Bugzilla #1644
  Submitted by:	Xin Xia <xi...@yahoo.com>
  
  Revision  Changes    Path
  1.12      +6 -20     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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- IncludeTag.java	2001/05/03 03:29:36	1.11
  +++ IncludeTag.java	2001/05/09 04:42:10	1.12
  @@ -1,5 +1,5 @@
   /*
  - * $Id: IncludeTag.java,v 1.11 2001/05/03 03:29:36 craigmcc Exp $
  + * $Id: IncludeTag.java,v 1.12 2001/05/09 04:42:10 craigmcc Exp $
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -68,6 +68,7 @@
   import java.net.URLConnection;
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpServletRequest;
  +import javax.servlet.http.HttpServletResponse;
   import javax.servlet.http.HttpSession;
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.PageContext;
  @@ -90,7 +91,7 @@
    * wrapped response passed to RequestDispatcher.include().
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.11 $ $Date: 2001/05/03 03:29:36 $
  + * @version $Revision: 1.12 $ $Date: 2001/05/09 04:42:10 $
    */
   
   public class IncludeTag extends TagSupport {
  @@ -350,24 +351,9 @@
   
           // Append the session identifier if appropriate
           if (includeSession) {
  -            String sessionId = null;
  -            HttpServletRequest request =
  -                (HttpServletRequest) pageContext.getRequest();
  -            HttpSession session = request.getSession();
  -            try {
  -                sessionId = session.getId();
  -            } catch (Throwable t) {
  -                sessionId = null;
  -            }
  -            if (sessionId != null) {
  -                int question = href.indexOf('?');
  -                if (question < 0)
  -                    href += ";jsessionid=" + sessionId;
  -                else
  -                    href = href.substring(0, question) +
  -                        ";jsessionid=" + sessionId +
  -                        href.substring(question);
  -            }
  +            HttpServletResponse response =
  +                (HttpServletResponse) pageContext.getResponse();
  +            href = response.encodeURL(href);
           }
   
           // Convert the hyperlink to a URL