001 /*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016 package org.opengion.hayabusa.taglib;
017
018 import org.opengion.hayabusa.common.HybsSystem;
019 import org.opengion.hayabusa.common.HybsSystemException;
020 import org.opengion.hayabusa.resource.URLXfer;
021 import org.opengion.fukurou.util.StringUtil ;
022
023 import javax.servlet.http.HttpSession ;
024 import javax.servlet.http.HttpServletResponse;
025 import javax.servlet.http.HttpServletRequest;
026 import javax.servlet.jsp.tagext.TagSupport ;
027 import javax.servlet.jsp.JspWriter ;
028
029 import java.io.IOException;
030
031 /**
032 * マルãƒã‚»ãƒ?‚·ãƒ§ãƒ³èµ·å‹•ãƒã‚§ãƒ?‚¯ã‚’行ã„ã¾ã™ã?
033 *
034 * ã“ã?ã‚¿ã‚°ã¯ã€ç‰¹æ®Šã§ã€ä¸?•ªæœ?¸Šä½ã?JSP(通常ã¯ã€jsp/index.jsp)ã«ä»•è¾¼ã‚?“ã¨ã§ã€?
035 * マルãƒã‚»ãƒ?‚·ãƒ§ãƒ³èµ·å‹•ãƒã‚§ãƒ?‚¯ã‚’行ã„ã¾ã™ã?
036 * ã¨ãã«ã€TopMenuTag ã¨é–¢é€£ã—ã¦ãŠã‚Šã€ã“ã®ã‚¿ã‚°ãŒå˜åœ¨ã—ãªã?¨ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã?
037 * 動作ã—ã¾ã›ã‚“ã€?
038 * ã“ã?ã‚¿ã‚°ã§ã¯ã€URLXfer ã«ã‚ˆã‚‹ã€ãƒªãƒ³ã‚¯å¤‰æ›è»¢é€ã‚’サãƒã?トã—ã¾ã™ã?
039 * URLã®XFER変数をã‚ーã«ã€GE17 ãƒ??ブルを検索ã—ã?æŒ?®šã?URL㸠sendRedirect ã—ã¾ã™ã?
040 *
041 * @og.formSample
042 * â—å½¢å¼ï¼?lt;og:jspInit />
043 * â—body?šãªã?
044 *
045 * â—使用ä¾?
046 * <og:jspInit />
047 *
048 * @og.rev 4.0.0.0 (2005/08/31) æ–°è¦ä½œæ?
049 * @og.group メニュー制御
050 *
051 * @version 4.0
052 * @author Kohei Naruse
053 * @since JDK5.0,
054 */
055 public class JspInitTag extends TagSupport {
056 //* ã“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã—ã¾ã™ã? {@value} */
057 private static final String VERSION = "5.7.6.2 (2014/05/16)" ;
058
059 private static final long serialVersionUID = 576220140516L ;
060
061 // 3.8.0.0 (2005/06/07)
062 private static int count = 0;
063
064 /**
065 * Taglibã®çµ‚äº?‚¿ã‚°ãŒè¦‹ã¤ã‹ã£ãŸã¨ãã«å‡¦ç?™ã‚?doEndTag() ã‚?オーãƒã?ライドã—ã¾ã™ã?
066 *
067 * @og.rev 4.1.1.0 (2008/02/07) UserInfo ã®å†ä½œæ?ã™ã‚‹æ©Ÿè?を追åŠ?
068 * @og.rev 4.2.2.0 (2008/05/28) Guestユーザ対�
069 * @og.rev 4.3.4.1 (2008/12/08) UserInfo ã®å†ä½œæ?ã™ã‚‹æ©Ÿè?を削除
070 * @og.rev 5.7.4.3 (2014/03/28) 出力ã™ã‚?HTML ã¯ã€ãƒ•ィルターã—ã¾ã™ã?
071 * @og.rev 5.7.6.2 (2014/05/16) IEã®HTML5機è?ãŒæœ‰åйã‹ç„¡åйã‹ã?判定ã‚ーを削除(åˆæœŸåŒ?ã—ã¾ã™ã?
072 *
073 * @return 後続å?ç??æŒ?¤º
074 */
075 @Override
076 public int doEndTag() {
077 // 5.7.4.3 (2014/03/28) エラー時ã§ã‚‚ã?debug=true ãŒã‚れã?ã€ç¶™ç¶šã™ã‚‹ã?
078 HttpServletRequest request = ( HttpServletRequest )pageContext.getRequest();
079 boolean debug = "true".equalsIgnoreCase( request.getParameter( "debug" ) );
080
081 // Tomcat åˆæœŸèµ·å‹•時㮠common/SystemParameter.java ã§ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå?åˆã?
082 String errMsg = HybsSystem.sys( HybsSystem.LOCAL_CONTX_ERR_KEY );
083 if( errMsg != null && !debug ) {
084 try {
085 JspWriter out = pageContext.getOut();
086 out.println( "<html><body><pre>" );
087 // 5.7.4.3 (2014/03/28) 出力ã™ã‚?HTML ã¯ã€ãƒ•ィルターã—ã¾ã™ã?
088 out.println( StringUtil.htmlFilter( errMsg ) );
089 out.println( "</pre></body></html>" );
090 }
091 catch(IOException ex) {
092 errMsg = "ç”»é¢å‡ºåŠ›æ™‚ã® PageContext ã®å–得時ã«ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ã¾ã—ãŸã€?
093 + HybsSystem.CR
094 + errMsg ;
095 throw new HybsSystemException( errMsg,ex ); // 3.5.5.4 (2004/04/15) 引数ã®ä¸¦ã³é ?¤‰æ›´
096 }
097 return SKIP_PAGE ; // ペã?ã‚¸ã®æ®‹ã‚Šã®å‡¦ç?‚’行ã‚ãªã??
098 }
099
100 HttpSession session = pageContext.getSession();
101 synchronized( JspInitTag.class ) {
102 // 3.8.0.0 (2005/06/07) åŒä¸?‚»ãƒ?‚·ãƒ§ãƒ³ã§ã®ãƒžãƒ«ãƒèµ·å‹•対ç–を行ã„ã¾ã™ã?
103 String cnt = String.valueOf( count++ ) ;
104 session.setAttribute( HybsSystem.MULTI_SESSION_CHECK, cnt );
105 }
106
107 // 5.7.6.2 (2014/05/16) IEã®HTML5機è?ãŒæœ‰åйã‹ç„¡åйã‹ã?判定ã‚ーを削除(åˆæœŸåŒ?ã—ã¾ã™ã?
108 session.removeAttribute( HybsSystem.IE_HTML5_KEY );
109
110 // URLXfer ã«ã‚ˆã‚‹ã€ãƒªãƒ³ã‚¯å¤‰æ›è»¢é€æ©Ÿè?
111 String key = request.getParameter( "XFER" );
112 if( key != null ) {
113 URLXfer xfer = new URLXfer();
114 String url = xfer.getRedirectURL( key );
115 if( url != null ) {
116 try {
117 HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
118 response.sendRedirect( url );
119 return SKIP_PAGE ; // ペã?ã‚¸ã®æ®‹ã‚Šã®å‡¦ç?‚’行ã‚ãªã??
120 } catch ( IOException ex ) {
121 String errMsg2 = "URLã®æŒ¯ã‚Šå?ã‘å?ç?™‚ã« IOException ãŒç™ºç”Ÿã—ã¾ã—ãŸã€?XFER=" + key;
122 throw new HybsSystemException( errMsg2,ex );
123 }
124 }
125 }
126
127 return EVAL_PAGE ; // ペã?ã‚¸ã®æ®‹ã‚Šã‚’評価ã™ã‚‹ã€?
128 }
129 }