<%@ page import="com.objective.oji.*"%> <%@ page import="java.lang.*"%> <%@ page import="java.net.*"%> <%@ page import="oracle.jdbc.pool.OracleDataSource"%> <%@ page import="java.sql.*"%> <%@ page import="java.util.*"%> <%@ page import="java.text.*"%> <% // This jsp calls two other jsp files: alias.jsp and nodoc.jsp // alias.jsp is used to handle the reading of document aliases // nodoc.jsp is used to display an error page when the document cannot be found // // Note: there are a number of places within the code where user ids, server names // passwords and ip addresses have been removed. You will have to replace these // with the appropriate text for your own installation. //Read querystring to get ID number String oid="A5533"; // an error page try { oid = request.getParameter("oid").toUpperCase(); } catch(Exception e) { oid = "A5533"; } // application object OjiApplication objective = new OjiApplication(); // deal with alias's // a document alias always begins with the letter z if( oid.substring(0,1).equals("Z") ) { response.sendRedirect( "alias.jsp?oid=" + oid ); } // login to the server OjiSession apiSession = objective.loginUser("username", "password", "server", portNumber); //Get Object from Objective server OjiObject obj = apiSession.getObject( oid ); OjiDocument doc = (OjiDocument) obj; OjiDocVersion ver; try { ver = DOC.getCurrentVersion(); } catch(Exception e) { response.sendRedirect( "nodoc.jsp?oid=" + oid ); } //Copy file onto intranet server String extension = ver.getFileType().toLowerCase(); // make a web-safe version of the filename, replacing any dodgy characters String safeLabel = obj.getLabelForView(); char qu = (char) 34; String quotes = "" + qu; char bs = (char) 92; String backslash = "" + bs; safeLabel = safeLabel.replaceAll(quotes,""); safeLabel = safeLabel.replaceAll("\\"+backslash+"+",""); safeLabel = safeLabel.replaceAll("/",""); safeLabel = safeLabel.replaceAll(":",""); safeLabel = safeLabel.replaceAll("\\*+",""); safeLabel = safeLabel.replaceAll("\\?+",""); safeLabel = safeLabel.replaceAll("<",""); safeLabel = safeLabel.replaceAll(">",""); safeLabel = safeLabel.replaceAll("\\|+",""); int maxLength = 100; if( safeLabel.length() > maxLength ) { safeLabel = safeLabel.substring( 0, maxLength ) + "..."; } String filename= "[" + oid + "] " + safeLabel + "." + extension; String server=request.getServerName().toLowerCase(); String base=""; if ( server.equals( "" ) || server.equals( "" ) ) { try { // get the file from Objective and put in on the application server ver.getRemoteFile( "" + filename); } catch(Exception e) { response.sendRedirect("nodoc.jsp?oid=" + oid ); } base="http://://"; } apiSession.logout(); response.sendRedirect( base + filename ); %> Error encountered. Should have been redirected to view document <%=filename%>.