/** * run the given script * @param language - the language of the script * @param script - the script to run */ public String runScript( String language, String script ) { if (!supportsScriptLanguage( language )) return ""; try { script = script.trim(); if (script.startsWith( "<!--" )) { script = withoutFirstLine( script ); if (script.endsWith( "-->" )) script = script.substring( 0, script.lastIndexOf( "-->" )); } Context context = Context.enter(); context.initStandardObjects( null ); context.evaluateString( this, script, "httpunit", 0, null ); return getDocumentWriteBuffer(); } catch (Exception e) { handleScriptException( e, "Script '" + script + "'" ); return ""; } finally { discardDocumentWriteBuffer(); Context.exit(); } }
/** * run the given script * @param language - the language of the script * @param script - the script to run */ public String runScript( String language, String script ) { if (!supportsScriptLanguage( language )) return ""; try { script = script.trim(); if (script.startsWith( "<!--" )) { script = withoutFirstLine( script ); if (script.endsWith( "-->" )) script = script.substring( 0, script.lastIndexOf( "-->" )); } Context context = Context.enter(); context.initStandardObjects( null ); context.evaluateString( this, script, "httpunit", 0, null ); return getDocumentWriteBuffer(); } catch (Exception e) { handleScriptException( e, "Script '" + script + "'" ); return ""; } finally { discardDocumentWriteBuffer(); Context.exit(); } }
/** * run the given script * @param language - the language of the script * @param script - the script to run */ public String runScript( String language, String script ) { if (!supportsScriptLanguage( language )) return ""; try { script = script.trim(); if (script.startsWith( "<!--" )) { script = withoutFirstLine( script ); if (script.endsWith( "-->" )) script = script.substring( 0, script.lastIndexOf( "-->" )); } Context context = Context.enter(); context.initStandardObjects( null ); context.evaluateString( this, script, "httpunit", 0, null ); return getDocumentWriteBuffer(); } catch (Exception e) { handleScriptException( e, "Script '" + script + "'" ); return ""; } finally { discardDocumentWriteBuffer(); Context.exit(); } }