<% 
  String enc = request.getParameter("enc");
  if ((enc == null) || "".equals(enc))
    response.setContentType("text/html");
  else
    response.setContentType("text/html;charset=" + enc);
%>
<%@ page import='oracle.cabo.share.config.Configuration'%>
<%@ page import='oracle.cabo.ui.ServletRenderingContext'%>
<%@ page import='oracle.cabo.ui.UIConstants'%>
<%@ page import='oracle.cabo.ui.beans.HeadBean'%>
<%@ page import='oracle.cabo.ui.beans.ScriptBean'%>
<%@ page import='oracle.cabo.ui.html.HTMLWebBean'%>

<%//567890123456789012345678901234567890123456789012345678901234567890123456789
  ServletRenderingContext rContext = new ServletRenderingContext(pageContext);

  //
  // set the correct configuration
  //
  rContext.setConfiguration((String)request.getParameter("configName"));

  // Set the context URI and path if they are specified
  String contextURI = (String)request.getParameter("contextURI");
  if (contextURI != null)
  {
    rContext.setProperty(UIConstants.MARLIN_NAMESPACE,
                         rContext.CONTEXT_URI_PROPERTY,
                         contextURI);
  }

  String contextPath = (String)request.getParameter("contextPath");
  if (contextPath != null)
  {
    rContext.setProperty(UIConstants.MARLIN_NAMESPACE,
                         rContext.CONTEXT_PATH_PROPERTY,
                         contextPath);
  }

%><jsp:useBean id="root"
             scope="request"
             class="oracle.cabo.ui.beans.DocumentBean"><%

  HeadBean head = new HeadBean();

  Configuration conf = rContext.getConfiguration();

  // Use the shared context to locate the JSLIBs directory, if 
  // we've got a shared context.  We look for the special secret
  // "_sharedContext" property on the RenderingContext to determine
  // whether we've got shared installables.
  if (rContext.getProperty(UIConstants.MARLIN_NAMESPACE, "_sharedContext") !=
      null)
  {
    // If we have got a shared context for our installables, we always
    // use an empty context URI when resolving URLs...
    contextURI = "";
  }

  // If we aren't using shared installables just use the local context URI
  if (contextURI == null)
  {
    contextURI = (String)rContext.getProperty(UIConstants.MARLIN_NAMESPACE, 
                                              rContext.CONTEXT_URI_PROPERTY);
  }

  String baseURL = conf.getURI(Configuration.JSLIBS_DIRECTORY, contextURI);
  ScriptBean marlinCore = new ScriptBean();
  marlinCore.setSource(baseURL + "MarlinCore.js");

  head.addIndexedChild(marlinCore);
  root.setMetaContainer(head);
  
  HTMLWebBean contentFrame = new HTMLWebBean("frame");
  
  String redirectString = request.getParameter("redirect");
  
  if (redirectString != null)
  {
    contentFrame.setHTMLAttributeValue("src",
                                       redirectString + 
                                       "?"            +
                                       request.getQueryString());
  }
  
  HTMLWebBean frameSet = new HTMLWebBean("frameset");
  frameSet.addIndexedChild(contentFrame);

  frameSet.setAttributeValue("rows", "100%,*");
  frameSet.setAttributeValue("border", "0");
  // Set the title to the title of the content, and then shrink (or expand)
  // the window to fit the content.  The 25 pixel fudge factor is purely
  // a hack to handle calendarDialog, which regularly needs to grow
  // a line or two.  A better method that accounts for font heights
  // would be good...
  frameSet.setAttributeValue("onload",
                             "window.document.title = window.frames[0].document.title; _sizeWin(window.frames[0],0,25)");
  frameSet.setAttributeValue("onunload", "_checkUnload(event)");
  root.addIndexedChild(frameSet);
  
%></jsp:useBean><%
  root.render(rContext);
%>