⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ordgetmediajsp.jsp

📁 相当板扎,采用贝叶斯公式的垃圾邮件过滤程序
💻 JSP
字号:
<%--
  *  @author   Fengting Chen
  *  @version  1.0
  *
  *  Name of the Application        : OrdGetMediaJsp.jsp
  *  Development Environment        : Oracle JDeveloper 10g
  *  Creation/Modification History  :
  *
  *     Fengting Chen    02-Jan-2004     Created
  *
  *  Overview of Application        :
  *    This JSP operates as a media delivery JSP page. 
--%>

<%@ page language="java" %>
<%@ page import="oracle.jdbc.pool.OracleConnectionCache" %>
<%@ page import="oracle.ord.im.jsp.*" %>
<%@ page import="oracle.ord.im.*" %>
<%@ page import="java.util.HashSet" %>
<%@ page import="java.io.InputStream" %>

<jsp:useBean id="rhandler" scope="page"
             class = "oracle.ord.im.OrdHttpJspResponseHandler"/>
<jsp:useBean id="mhandler" scope="page"
             class = "oracle.ord.im.jsp.OrdMediaDBAccessHandler"/>

<jsp:setProperty name="mhandler" 
                 property="dataSourceName" param="dataSourceName"/>

<jsp:setProperty name="mhandler" 
                 property="table" param="table"/>

<jsp:setProperty name="mhandler" 
                 property="mediaColumns" param="column"/>

<jsp:setProperty name="mhandler" 
                 property="key" param="key"/>

<jsp:setProperty name="mhandler" 
                 property="keyColumn" param="keyColumn"/>

<jsp:setProperty name="mhandler" 
                 property="rowid" param="rowid"/>

<%
    // Check the authorization
    boolean authorized = false;

    // Get the table, column info from the session context first
    HashSet hs = (HashSet)pageContext.getAttribute(
                                    OrdJspTagUtil.TABLE_COLUMN_KEY,
                                    PageContext.SESSION_SCOPE);
    String table = request.getParameter("table");
    String column = request.getParameter("column");
    boolean inSameSession = false;
    if (hs != null && hs.contains(table+"+"+column))
        inSameSession = true;

    String connCacheName = request.getParameter("connCacheName");
    String dataSourceName = request.getParameter("dataSourceName");
    if (dataSourceName != null) 
    {
        if (inSameSession) 
        {
            String sName = (String)pageContext.getAttribute(
                                            OrdJspTagUtil.DATASOURCE_KEY, 
                                            PageContext.SESSION_SCOPE);
            if (sName != null && sName.equals(dataSourceName))
                authorized = true;
        } 
        else 
        {
            OrdJspTagConfig cfg = (OrdJspTagConfig)pageContext.getAttribute(
                                            OrdJspTagUtil.TAG_CONFIG_KEY,
                                            PageContext.APPLICATION_SCOPE);
            if (cfg == null)
            {
                // Read the configuration file
                InputStream cstr = application.getResourceAsStream(
                                            OrdJspTagUtil.CONFIG_FILE_NAME);

                if (cstr != null)
                {
                    cfg = OrdJspTagUtil.getOrdJspTagConfig(cstr);
                }
            }

            if (cfg != null) 
            {
                authorized = !(cfg.isMediaUnderControl(dataSourceName, 
                                                        table, column));
            }    
        }
     } 
     else if (connCacheName != null) 
     {
        OracleConnectionCache occ = 
          (OracleConnectionCache)pageContext.getAttribute(connCacheName, 
                                 PageContext.SESSION_SCOPE);
        if (occ != null && inSameSession) 
        {
            mhandler.setConnCache(occ);
            authorized = true;
        }
    } 
     // Raise error
     if (!authorized) 
     {
        ((HttpServletResponse)pageContext.getResponse()).sendError(
                                        HttpServletResponse.SC_NOT_FOUND);
        return;
     }


    String expiration = request.getParameter("expiration");
    String cache = request.getParameter("cache");

    rhandler.setPageContext(pageContext);

    // Set cache control attribute
     if (cache != null)
     {
        if ("no".equals(cache))
               rhandler.setHeader("Surrogate-Control", "no-store");
        else if ("no-remote".equals(cache))
               rhandler.setHeader("Surrogate-Control", "no-store-remote");
     }
     if (expiration != null && (cache == null || cache.equals("yes")))
     {
        rhandler.setHeader("Surrogate-Control", "max-age = "+expiration);
     }

     // Use try-finally to ensure the release of the jdbc connection
     try{
        Object[] objs = mhandler.getMediaObjects();

        if (objs == null) {
           ((HttpServletResponse)pageContext.getResponse()).sendError(
                                            HttpServletResponse.SC_NOT_FOUND);
           return;
        }

        byte[] ctx[] = new byte[4000][1];
        if (objs[0] instanceof OrdImage)
        {
           try{
             if (((OrdImage)objs[0]).getMimeType() == null)
               ((OrdImage)objs[0]).setProperties();
           } catch (Exception e) {}
           
           rhandler.sendImage((OrdImage)objs[0]);
        }
        else if (objs[0] instanceof OrdAudio)
        {
           try{
             if (((OrdAudio)objs[0]).getMimeType() == null)
               ((OrdAudio)objs[0]).setProperties(ctx);
           } catch (Exception e) {}
           rhandler.sendAudio((OrdAudio)objs[0]);
        }
        else if (objs[0] instanceof OrdVideo)
        {
           try{
             if (((OrdVideo)objs[0]).getMimeType() == null)
               ((OrdVideo)objs[0]).setProperties(ctx);
           } catch (Exception e) {}

           rhandler.sendVideo((OrdVideo)objs[0]);
        }



    } finally {

        mhandler.release();
    }

    if(true)
      return;
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -