Help with Java script

So , I edited the ITunes.java as described in the Admin guide.Copied the .class to my cgi folder in the server.I copied the itunesu file from the shell folder of the sample code.I have modified it accordingly.But when I run it in browser(Firefox) as ..../cgi-bin/itunesu it just gives me a blank page.Nothing shows up.I ran the ITunes.java file locally and it generates an HTML output, which I copied and created a new html.After I run this HTML file, it opens my itunes, but again it says page not found and url contains https://www.xxx.edu/cgi-bin/itunesu?destination=xxx.edu where xxx is my institution name.Not sure if I am supposed to display my institution name in forum.
The admin guide says on page 15 step 4.Copy the itunes.class file and other itunes file to your web server's cgi-bin directory.
I am not quiet sure what does other itunes file mean??
This is how my .java file looks.
import java.io.*;
import java.net.*;
import java.security.*;
import java.util.*;
* The <CODE>ITunesU</CODE> class permits the secure transmission
* of user credentials and identity between an institution's
* authentication and authorization system and iTunes U.
* The code in this class can be tested by
* running it with the following commands:
* <PRE>
* javac ITunesU.java
* java ITunesU</PRE>
* Changes to values defined in this class' main() method must
* be made before it will succesfully communicate with iTunes U.
public class ITunesU extends Object {
* Generate the HMAC-SHA256 signature of a message string, as defined in
* RFC 2104.
* @param message The string to sign.
* @param key The bytes of the key to sign it with.
* @return A hexadecimal representation of the signature.
public String hmacSHA256(String message, byte[] key) {
// Start by getting an object to generate SHA-256 hashes with.
MessageDigest sha256 = null;
try {
sha256 = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
throw new java.lang.AssertionError(
this.getClass().getName()
+ ".hmacSHA256(): SHA-256 algorithm not found!");
// Hash the key if necessary to make it fit in a block (see RFC 2104).
if (key.length > 64) {
sha256.update(key);
key = sha256.digest();
sha256.reset();
// Pad the key bytes to a block (see RFC 2104).
byte block[] = new byte[64];
for (int i = 0; i < key.length; ++i) block = key;
for (int i = key.length; i < block.length; ++i) block = 0;
// Calculate the inner hash, defined in RFC 2104 as
// SHA-256(KEY ^ IPAD + MESSAGE)), where IPAD is 64 bytes of 0x36.
for (int i = 0; i < 64; ++i) block ^= 0x36;
sha256.update(block);
try {
sha256.update(message.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new java.lang.AssertionError(
"ITunesU.hmacSH256(): UTF-8 encoding not supported!");
byte[] hash = sha256.digest();
sha256.reset();
// Calculate the outer hash, defined in RFC 2104 as
// SHA-256(KEY ^ OPAD + INNER_HASH), where OPAD is 64 bytes of 0x5c.
for (int i = 0; i < 64; ++i) block ^= (0x36 ^ 0x5c);
sha256.update(block);
sha256.update(hash);
hash = sha256.digest();
// The outer hash is the message signature...
// convert its bytes to hexadecimals.
char[] hexadecimals = new char[hash.length * 2];
for (int i = 0; i < hash.length; ++i) {
for (int j = 0; j < 2; ++j) {
int value = (hash >> (4 - 4 * j)) & 0xf;
char base = (value < 10) ? ('0') : ('a' - 10);
hexadecimals[i * 2 + j] = (char)(base + value);
// Return a hexadecimal string representation of the message signature.
return new String(hexadecimals);
* Combine user credentials into an appropriately formatted string.
* @param credentials An array of credential strings. Credential
* strings may contain any character but ';'
* (semicolon), '\\' (backslash), and control
* characters (with ASCII codes 0-31 and 127).
* @return <CODE>null</CODE> if and only if any of the credential strings
* are invalid.
public String getCredentialsString(String[] credentials) {
// Create a buffer with which to generate the credentials string.
StringBuffer buffer = new StringBuffer();
// Verify and add each credential to the buffer.
if (credentials != null) {
for (int i = 0; i < credentials.length; ++i) {
if (i > 0) buffer.append(';');
for (int j = 0, n = credentials.length(); j < n; ++j) {
char c = credentials.charAt(j);
if (c != ';' && c != '\\' && c >= ' ' && c != 127) {
buffer.append(c);
} else {
return null;
// Return the credentials string.
return buffer.toString();
* Combine user identity information into an appropriately formatted string.
* @param displayName The user's name (optional).
* @param emailAddress The user's email address (optional).
* @param username The user's username (optional).
* @param userIdentifier A unique identifier for the user (optional).
* @return A non-<CODE>null</CODE> user identity string.
public String getIdentityString(String displayName, String emailAddress,
String username, String userIdentifier) {
// Create a buffer with which to generate the identity string.
StringBuffer buffer = new StringBuffer();
// Define the values and delimiters of each of the string's elements.
String[] values = { displayName, emailAddress,
username, userIdentifier };
char[][] delimiters = { { '"', '"' }, { '<'(', ')' }, { '[', ']' } };
// Add each element to the buffer, escaping
// and delimiting them appropriately.
for (int i = 0; i < values.length; ++i) {
if (values != null) {
if (buffer.length() > 0) buffer.append(' ');
buffer.append(delimiters[0]);
for (int j = 0, n = values.length(); j < n; ++j) {
char c = values.charAt(j);
if (c == delimiters[1] || c == '\\') buffer.append('\\');
buffer.append(c);
buffer.append(delimiters[1]);
// Return the generated string.
return buffer.toString();
* Generate an iTunes U digital signature for a user's credentials
* and identity. Signatures are usually sent to iTunes U along
* with the credentials, identity, and a time stamp to warrant
* to iTunes U that the credential and identity values are
* officially sanctioned. For such uses, it will usually makes
* more sense to use an authorization token obtained from the
* {@link #getAuthorizationToken(java.lang.String, java.lang.String, java.util.Date, byte[])}
* method than to use a signature directly: Authorization
* tokens include the signature but also the credentials, identity,
* and time stamp, and have those conveniently packaged in
* a format that is easy to send to iTunes U over HTTPS.
* @param credentials The user's credentials string, as
* obtained from getCredentialsString().
* @param identity The user's identity string, as
* obtained from getIdentityString().
* @param time Signature time stamp.
* @param key The bytes of your institution's iTunes U shared secret key.
* @return A hexadecimal representation of the signature.
public String getSignature(String credentials, String identity,
Date time, byte[] key) {
// Create a buffer in which to format the data to sign.
StringBuffer buffer = new StringBuffer();
// Generate the data to sign.
try {
// Start with the appropriately encoded credentials.
buffer.append("credentials=");
buffer.append(URLEncoder.encode(credentials, "UTF-8"));
// Add the appropriately encoded identity information.
buffer.append("&identity=");
buffer.append(URLEncoder.encode(identity, "UTF-8"));
// Add the appropriately formatted time stamp. Note that
// the time stamp is expressed in seconds, not milliseconds.
buffer.append("&time=");
buffer.append(time.getTime() / 1000);
} catch (UnsupportedEncodingException e) {
// UTF-8 encoding support is required.
throw new java.lang.AssertionError(
"ITunesU.getSignature(): UTF-8 encoding not supported!");
// Generate and return the signature.
String signature = this.hmacSHA256(buffer.toString(), key);
return signature;
* Generate and sign an authorization token that you can use to securely
* communicate to iTunes U a user's credentials and identity. The token
* includes all the data you need to communicate to iTunes U as well as
* a creation time stamp and a digital signature for the data and time.
* @param credentials The user's credentials string, as
* obtained from getCredentialsString().
* @param identity The user's identity string, as
* obtained from getIdentityString().
* @param time Token time stamp. The token will only be valid from
* its time stamp time and for a short time thereafter
* (usually 90 seconds).
* @param key The bytes of your institution's iTunes U shared secret key.
* @return The authorization token. The returned token will
* be URL-encoded and can be sent to iTunes U with
* a form
* submission. iTunes U will typically respond with
* HTML that should be sent to the user's browser.
public String getAuthorizationToken(String credentials, String identity,
Date time, byte[] key) {
// Create a buffer with which to generate the authorization token.
StringBuffer buffer = new StringBuffer();
// Generate the authorization token.
try {
// Start with the appropriately encoded credentials.
buffer.append("credentials=");
buffer.append(URLEncoder.encode(credentials, "UTF-8"));
// Add the appropriately encoded identity information.
buffer.append("&identity=");
buffer.append(URLEncoder.encode(identity, "UTF-8"));
// Add the appropriately formatted time stamp. Note that
// the time stamp is expressed in seconds, not milliseconds.
buffer.append("&time=");
buffer.append(time.getTime() / 1000);
// Generate and add the token signature.
String data = buffer.toString();
buffer.append("&signature=");
buffer.append(this.hmacSHA256(data, key));
} catch (UnsupportedEncodingException e) {
// UTF-8 encoding support is required.
throw new java.lang.AssertionError(
"ITunesU.getAuthorizationToken(): "
+ "UTF-8 encoding not supported!");
// Return the signed authorization token.
return buffer.toString();
* Send a request for an action to iTunes U with an authorization token.
* @param url URL defining how to communicate with iTunes U and
* identifying which iTunes U action to invoke and which iTunes
* U page or item to apply the action to. Such URLs have a
* format like <CODE>[PREFIX]/[ACTION]/[DESTINATION]</CODE>,
* where <CODE>[PREFIX]</CODE> is a value like
* "https://deimos.apple.com/WebObjects/Core.woa" which defines
* how to communicate with iTunes U, <CODE>[ACTION]</CODE>
* is a value like "Browse" which identifies which iTunes U
* action to invoke, and <CODE>[DESTINATION]</CODE> is a value
* like "example.edu" which identifies which iTunes U page
* or item to apply the action to. The destination string
* "example.edu" refers to the root page of the iTunes U site
* identified by the domain "example.edu". Destination strings
* for other items within that site contain the site domain
* followed by numbers separated by periods. For example:
* "example.edu.123.456.0789". You can find these
* strings in the items' URLs, which you can obtain from
* iTunes. See the iTunes U documentation for details.
* @param token Authorization token generated by getAuthorizationToken().
* @return The iTunes U response, which may be HTML or
* text depending on the type of action invoked.
public String invokeAction(String url, String token) {
// Send a request to iTunes U and record the response.
StringBuffer response = null;
try {
// Verify that the communication will be over SSL.
if (!url.startsWith("https")) {
throw new MalformedURLException(
"ITunesU.invokeAction(): URL \""
+ url + "\" does not use HTTPS.");
// Create a connection to the requested iTunes U URL.
HttpURLConnection connection =
(HttpURLConnection)new URL(url).openConnection();
connection.setUseCaches(false);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty(
"Content-Type",
"application/x-www-form-urlencoded; charset=UTF-8");
// Send the authorization token to iTunes U.
connection.connect();
OutputStream output = connection.getOutputStream();
output.write(token.getBytes("UTF-8"));
output.flush();
output.close();
// Read iTunes U's response.
response = new StringBuffer();
InputStream input = connection.getInputStream();
Reader reader = new InputStreamReader(input, "UTF-8");
reader = new BufferedReader(reader);
char[] buffer = new char[16 * 1024];
for (int n = 0; n >= 0;) {
n = reader.read(buffer, 0, buffer.length);
if (n > 0) response.append(buffer, 0, n);
// Clean up.
input.close();
connection.disconnect();
} catch (UnsupportedEncodingException e) {
// ITunes U requires UTF-8 and ASCII encoding support.
throw new java.lang.AssertionError(
"ITunesU.invokeAction(): UTF-8 encoding not supported!");
} catch (IOException e) {
// Report communication problems.
throw new java.lang.AssertionError(
"ITunesU.invokeAction(): I/O Exception " + e);
// Return the response received from iTunes U.
return response.toString();
* iTunes U credential and identity transmission sample. When your
* itunes U site is initially created, Apple will send your institution's
* technical contact a welcome email with a link to an iTunes U page
* containing the following information, which you will need to customize
* this method's code for your site:
<DD><DL><DT>
* Information:<DD><CODE>
* Site URL</CODE> - The URL to your site in iTunes U. The last
* component of that URL, after the last slash,
* is a domain name that uniquely identifies your
* site within iTunes U.<DD><CODE>
* shared secret</CODE> - A secret key known only to you and Apple that
* allows you to control who has access to your
* site and what access they have to it.<DD><CODE>
* debug suffix</CODE> - A suffix you can append to your site URL
* to obtain debugging information about the
* transmission of credentials and identity
* information from your institution's
* authentication and authorization services
* to iTunes U.<DD><CODE>
* administrator credential</CODE> - The credential string to assign
* to users who should have the
* permission to administer your
* iTunes U site.</DL></DD>
<DD>
* Once you have substitute the information above in this method's code
* as indicated in the code's comments, this method will connect
* to iTunes U and obtain from it the HTML that needs to be returned to a
* user's web browser to have a particular page or item in your iTunes U
* site displayed to that user in iTunes. You can modify this method to
* instead output the URL that would need to be opened to have that page
* or item displayed in iTunes.</DD>
public static void main(String argv[]) {
// Define your site's information. Replace these
// values with ones appropriate for your site.
String siteURL =
"https://deimos.apple.com/WebObjects/Core.woa/Browse/xxx.edu" ;
String debugSuffix = "/abc123";
String sharedSecret = "some key";
String administratorCredential =
"Administrator@urn:mace:itunesu.com:sites:xxx.edu";
// Define the user information. Replace the credentials with the
// credentials you want to grant to the current user, and the
// optional identity information with the identity of that user.
// For initial testing and site setup, use the singe administrator
// credential defined when your iTunes U site was created. Once
// you have access to your iTunes U site, you will be able to define
// additional credentials and the iTunes U access they provide.
String[] credentialsArray = { administratorCredential };
String displayName = "my name";
String emailAddress = "my [email protected]";
String username = "mylogin";
String userIdentifier = "1243";
// Define the iTunes U page to browse. Use the domain name that
// uniquely identifies your site in iTunes U to browse to that site's
// root page; use a destination string extracted from an iTunes U URL
// to browse to another iTunes U page; or use a destination string
// supplied as the "destination" parameter if this program is being
// invoked as a part of the login web service for your iTunes U site.
String siteDomain = siteURL.substring(siteURL.lastIndexOf('/') + 1);
String destination = siteDomain;
// Append your site's debug suffix to the destination if you want
// to receive an HTML page providing information about the
// transmission of credentials and identity between this program
// and iTunes U. Uncomment the following line for testing only.
//destination = destination + debugSuffix;
// Use an ITunesU instance to format the credentials and identity
// strings and to generate an authorization token for them.
ITunesU iTunesU = new ITunesU();
String identity = iTunesU.getIdentityString(displayName, emailAddress,
username, userIdentifier);
String credentials = iTunesU.getCredentialsString(credentialsArray);
Date now = new Date();
byte[] key = null;
try {
key = sharedSecret.getBytes("US-ASCII");
} catch (UnsupportedEncodingException e) {
throw new java.lang.AssertionError(
"ITunesU.hmacSH256(): US-ASCII encoding not supported!");
String token = iTunesU.getAuthorizationToken(credentials, identity,
now, key);
// Use the authorization token to connect to iTunes U and obtain
// from it the HTML that needs to be returned to a user's web
// browser to have a particular page or item in your iTunes U
// site displayed to that user in iTunes. Replace "/Browse/" in
// the code below with "/API/GetBrowseURL/" if you instead want
// to return the URL that would need to be opened to have that
// page or item displayed in iTunes.
String prefix = siteURL.substring(0, siteURL.indexOf(".woa/") + 4);
String url = prefix + "/Browse/" + destination;
String results = iTunesU.invokeAction(url, token);
System.out.println(results);
The itunes file from Shell folder has been modified as follows
DISPLAY_NAME= "myname"
EMAIL_ADDRESS="[email protected]"
USERNAME="mylogin"
USER_IDENTIFIER="1243"
all the other things in that file have been untouched.
I also generated the debug which looks like this
iTunes U Access Debugging
Received
Destination xxx.edu
Identity "my name" <[email protected]> (mylogin) [1243]
Credentials Administrator@urn:mace:itunesu.com:sites:xxx.edu
Time 1196706873
Signature 533870b8jshdidk333lfsf6a3143a55c132ec548a4d545bd79322402e8e2596e4
Analysis
The destination string is valid and the corresponding destination item was found.
The identity string is valid and provides the following information:
Display Name my name
Email Address [email protected]
Username mylogin
User Identifier 1243
The credential string is valid and contains the following recognized credential:
1. Administrator@urn:mace:itunesu.com:sites:xxx.edu
The time string is valid and corresponds to 2007-12-03 18:34:33Z.
The signature string is valid.
Access
Because the received signature and time were valid, the received identity and credentials were accepted by iTunes U.
In addition, the following 2 credentials were automatically added by iTunes U:
1. All@urn:mace:itunesu.com:sites:xxx.edu
2. Authenticated@urn:mace:itunesu.com:sites:xxx.edu
With these credentials, you have browsing, downloading, uploading, and editing access to the requested destination.
I am pretty new to this, and working on this for the first time.If someone could guide me through this would be pretty helpful.

This is only going to work under IE !
Go to your page template :
Modify the definition, make sur you have this :
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>#TITLE#</title>
#HEAD#
<Script language = javascript>
Browser = navigator.appName
Net = Browser.indexOf("Netscape")
Micro = Browser.indexOf("Microsoft")
Netscape = false
IE = false
if(Net >= 0) {Netscape = true}
if(Micro >= 0) {IE = true}
function XYpos() {
if (IE == true) {
xPos = event.screenX
yPos = event.screenY
alert(xPos + " left " + yPos + " down")
else if (Netscape == true) {alert("Script won't work: " + "\n" + "You're using Netscape")}
</script>
Modify the body definition, make sure you have this :
<body #ONLOAD# onMouseDown = XYpos()>
I didnt try it but it make sens to me... tell me if it works!
Flex
Homepage : http://www.insum.ca
InSum Solutions' blog : http://insum-apex.blogspot.com

Similar Messages

  • Sreaming at the top of my lungs for HELP with Java Script problem!

    Hello,
    I have this strange problem that no one seems to know why or how to fix it.Whenever I encounter a web site that has java scripting for anything pop ups or redirects to url's anything that says java script when I mouse over the link my browsers do nothing.That is for explorer 6.0 beta netscape 4.7 and netscape version 6.I have tried in another forum some suggestions but nothing changed even though I am told nothing is wrong with the java scripting.I used to be able to click java script's with all of these browsers but no longer.That was a few months ago.Now to try something new I tried to see if a new browser would work.I now have the latest version of Opera.It did work but using Opera on some sites limits what I can do so it doesn't solve my problem.Then I tried the Sun JavaHot browser it also worked but limits what I can do on some site's.I have Windows 98 & updated most of my dll's etc & my java is version 2 1.3.1.My java script is enabled in Explorer & netscape's & the security is at a minimum level.Please help me figure out why these other browsers work but the other's do not.I want to edit a web site of mine but I can't because of this problem.I am very frustrated by this and need as detailed help as I can get.Anything of a suggestion would be very much appreciated.But I am also not an expert on the working's of a computer so bear with me.
    Brian

    Hi,
    Well I am thinking that if anyone could know something about Java script it would be java developers.But anyways I had the previous version of explorer 5.0 & the java didn't work in it either.Now how weird is this,I opened netscape 4.7 today & the java scripts are suddenly working.This has me scratching my head wondering if my computer is possesed by some force beyond my capability to know...????Weird as it seems though the explorer still will not respond to a java script.
    Brian

  • Need help with Java Script to perform a calculation in Adobe Acrobat Pro 9 form

    I have a form (test) that I am creating in Adobe Acrobat Pro 9.
    I need help creating custom Java Script so I can get the desired answer.
    1) There are several questions in each group that require a numerical answer between 0-4
    2) There is a total field set up to sum the answers from all above questions
    3) The final "score" takes the answer from Step 2 above and divides by the total possible answer
    Any help on what Java Script I need to complete this would be greatly appreciated!
    I've attached a "spreadsheet" that shows it in more detail as well as what formulas I used in Excel to get the desired end result.
    Thanks in advance.

    Have you tried the "The field is the average of:"?

  • Need help with Java script calling an html page

    Hello -
    I have a bunch of web pages, that call a java script called "header.js". The "header.js" puts a header on the top of each web page. In the Java script, I have a gif (picture) that displays a logo and if you click on it, it will send to you a different website.
    I'd like to replace this gif with an actual web page. So, the "header" would actually be a web page and not some gif.
    Below is a snippet of the code and I'd like to replace the highlighted section with a web page called "header.html". I don't even know if this is possible.
    Can anyone tell me what I need to do? I know pretty much nothing about Javascripting so please be as detailed as you can. Thanks!
    /* Common header across all pages... */
    document.write('            <div id="header" class="clearfix">');
    document.write('                            <div id="left" class="float_left">');
    document.write('                                            <div id="logo"><a href="http://www.xyz.com/" onclick="window.open(this.href);return false;" onkeypress="window.open(this.href);return false;" target=_blank><img src="/images/xyz.gif" width="105" height="75" alt="" border="0" /></a></div>');
    document.write('                                            <div id="mainNav" class="clearfix"> ');
    document.write('                                                             <ul>');
    //document.write('                                                                         <li id="nav_controls"><a href="controls.html">Controls</a></li>');
    document.write('                                                                              <li id="nav_motion"><a href="motion.html">Motion</a></li>');
    document.write('                                                                              <li id="nav_sensor"><a href="sensor.html">Sensor</a></li>');
    document.write('                                                                              <li id="nav_encoder"><a href="encoder.html">Encoder</a></li>');
    document.write('                                                                              <li id="nav_system"><a href="system.html">System</a></li>');
    //document.write('<!--                                                                  <li id="nav_logs"><a href="#">Logs</a></li> -->');
    document.write('                                                             </ul>');
    document.write('                                            </div>');
    document.write('                            </div>');
    document.write('                            <div id="right" class="float_left">');
    document.write('                                            <div id="controls">');

    Well, the problem with this is that I'm not an expert on SSI and I really know nothing about javascripting...so I'm afraid of breaking the whole web site and also having to modify all the web pages that call this header.
    I'll have to read up on server side include...cause I don't know much about it.
    If I could do what I want with this "header.js", it would be a lot easier.

  • Help with Java Script / DHTML

    This is NOT a jsp question. It is about (D)HTML and JavaScript
    I have to write a JavaScript function which will return the 'value/text' of the html code snippet.
    If I pass simple text like 'hello world' it should return the same.
    If I pass a hyperlink like 'thelink' , it should return 'thelink'
    If I pass any form element like '<input type="text" value="abc">' it should return its value 'abc'
    The input to the function is String containg the html code snippet and return value is also String
    I want to write a generic java script function, so no hard coding...
    Since, I will running only MSIE, I can use MS specific JS/DHTML
    Any ideas are welcome.
    Thanks

    To be that generic, sounds like you should just have a couple of Regular Expressions that will analyze the input string, look for "<",">", and "value=....".
    Possibly just a couple of conditional checks, and 2 or 3 Regular Expression checks.
    BnB

  • Help with java script to generate filename without extension

    There is a java script that generates a filename on a photographic image for professional purposes ie. proofing etc.
    it currently displays the filename and extension (123.jpg) and i would like it to simply display the filename minus the extension (123)
    this is the string that commands the filename to show up in Photoshop CS.
    myTextRef.contents = docRef.name;
    any ideas on how to eliminate the extension?

    var n = docRef.name;
    myTextRef.contents = n.substring(0, n.lastIndexOf("."));???

  • Problems with Java Scripting API

    Hello Everyone!
    Guys, I need help with Java scripting API. A problem is that I cannot understand how can I operate Java Object's fields and methods from the script language. I have chosen embedded javascript to work with. And I can get the fields and methods of in-box java classes (such as ArrayList for example), but I cannot work with methods and fields from my own classes!
    Here is an example:
    public class ScriptingExample {  
        class MyClass {  
            int myfield = 5;  
            int getInt() {return 7;}  
        public void runExample() {  
            ScriptEngineManager mgr = new ScriptEngineManager();  
            List<ScriptEngineFactory> factories = mgr.getEngineFactories();  
            ScriptEngineManager factory = new ScriptEngineManager();  
            ScriptEngine engine = factory.getEngineByName("JavaScript");  
            MyClass mc = new MyClass();  
            try{  
                engine.put("mc", mc);  
                engine.eval("print(mc.myfield); print(mc.getInt())"); // or engine.eval("print(mc.myfield)");
            } catch (Exception e) {e.printStackTrace();}  
    }  If I run the code with the commented part it prints "undefined" instead of "5".
    If I run the code as it is it prints error instead of "7":
    undefinedjavax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot find function getInt. (<Unknown source>#1) in <Unknown source> at line number 1
    at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
    at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
    at javax.script.AbstractScriptEngine.eval(Unknown Source)
    at solutiondatabase.ScriptingExample.runExample(ScriptingExample.java:26)
    at solutiondatabase.Main.main(Main.java:49)
    How can I fix it?

    Guys,
    please let me raise this topic because several new questions emerged.
    (1) How can I get all the variables created inside my engine?
    There are two kinds of variables: first kind is Java obejcts put inside the engine and second kind is the variables created in my script, such as 'var a = 4;'. How can I list all the variables of that two kinds?
    (2) Is there is a way to make 'import static' to the engine? I dont want to write MyClass.MyEnum.MyEnumItem every time. Also, I cannot put the whole enum into the engine with engine.put("MyEnum", MyEnum); I can put only enum items separately: engine.put("MyEnum", MyEnum.EnumItemA);. Thats why I ask about static import.
    (3) How can I cast engine variables back to java variables inside my java code?
    Here is my example:
    package mypackage;
    import java.util.ArrayList;
    import java.util.List;
    import javax.script.ScriptEngine;
    import javax.script.ScriptEngineFactory;
    import javax.script.ScriptEngineManager;
    public class Main
         public static void main(String[] args) throws Exception 
              ScriptEngineManager mgr = new ScriptEngineManager();
              List<ScriptEngineFactory> factories = mgr.getEngineFactories();
              ScriptEngineManager factory = new ScriptEngineManager();
              ScriptEngine engine = factory.getEngineByName("JavaScript");
              ArrayList<Double> myList = new ArrayList<Double>();
              myList.add(5.0);                    
              engine.put("MyList", myList);     
              engine.eval("MyVar = MyList.get(0);");
              System.out.println((Double)engine.get("MyVar"));
    }The result is:
    Exception in thread "main" java.lang.ClassCastException: sun.org.mozilla.javascript.internal.NativeJavaObject cannot be cast to java.lang.Double
    +     at mypackage.Main.main(Main.java:28)+
    Is it possible to retrieve my Double java object from the engine?
    Edited by: Dmitry_MSK on Aug 6, 2010 1:56 AM

  • Problem with Java Script after upgrade from BW 3.5 to BI7

    Dear Colleagues,
    We're facing the issue with Java Script after upgrade of BW 3.5 to BI7.
    Just after update we checked the basic functionality and it occured that some of web templates that use Java Script don't work. They generate seelction screen, but after selection the screen becomes blank without any error messages.
    We're currently stucked since web templates weren't converted to BI7 version so they should work exactly as before the upgrade.
    We compared the Java code with other environment that was not upgraded - it's perfectly the same.
    The only explanation that comes to my mind is that some Java Script settings on the server level were changed during the upgrade but I have no idea where I can check that.
    Thanks in advance for any suggestions,
    Andrzej Bobula

    Hi Deepu,
    Thanks, it was great to read your reply and then few minutes later talk to you live on SDN Day!
    Unfortunately, http cache clean-up did not help. But there is another funny thing I found - for exactly the same 3.5 webtemplate html code returned from WebAS 3.5 was different then from 7.0.
    Unfortunately, this editor does not allow to paste complete code, even in CODE brackets, but here are main differences:
    <b>3.5</b>
       if (navigator.appName == "Microsoft Internet Explorer")
    <frame src="/sap/bw/BEx?SAP-LANGUAGE=E&PAGENO=1&REQUEST_NO=1&CMD=GET_TEMPLATE"
    name="Content">
    and
    <b>7.0</b>
       if (navigator.appName.indexOf("Microsoft Internet Explorer")!=-1)
    <frame src="/sap/bw/BEx?SAP-LANGUAGE=E&PAGENO=8&REQUEST_NO=0&CMD=GET_TEMPLATE"
    name="Content" 0nLoad="javascript:loadTitle()">
    (I intentionaly put 0 i/o o in 0nLoad, otherwise Forum's editor does not accept the text.
    How about SAP's claim that technical upgrade from 3.x to 7.0 changes nothing?
    Regards,
    Vitaliy

  • Web site with Java Scripts ( on iphone4)

    try to open a web site with Java scripts , but it just show empty on the scripts section , anyone can help ? (on iphone 4 with iOS 4.1)

    Hi, welcome to Apple Discussions.
    Web pages that make use of Javascript should work just fine. Those that have embedded Java applications won't. Java & Javascript are two different animals despite the similarity in the names. Like Flash, Java is not supported on iOS.
    tt2

  • Need help in Java Script

    i Need some help in Java Script,
    am using the following code :
    <script type="text/javascript">
    var newwindow;
    function poptastic(url)
    newwindow=window.open(url,'name','height=300,width=400,left=100, top=100,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
    if (window.focus) {newwindow.focus()}
    else {newwindow.close()}
    //     if (window.focus) {newwindow.focus()}
    </script>
    In HTML,
    thWorld Environment
    Day, June 5<sup>th</sup>,2005
    Am using onmouseover event, so that when my mouse in on the link, popup is opened....and when my mouse is out of the link, the new window should b closed....
    but according to the above code, the new window is opened but have to close it manually....
    Is there any other way to close the popup when my mouse is out of the link

    Prawn,
    This is not really a good way to make friends. With the cross posting and the posting in a wrong forum anyway thing you have going.
    Please kindly take your question to an appropriate JavaScript forum.
    Have a happy day.
    Cross post from http://forum.java.sun.com/thread.jspa?messageID=3797201

  • Help with java mapping

    PI File adapter has a processing option u2018Empty-Message Handlingu2019 to ignore or Write Empty Files. In case there is no data created after mapping on target side then this option determines whether to write an empty file or not. But there is a catch to this option when it comes to using it with File Content Conversion which is described in SAP Note u2018821267u2019. It states following:
    I configure the receiver channel with File content conversion mode and I set the 'Empty Message Handling' option to ignore. Input payload to the receiver channel is generated out of mapping and it does not have any record sets. However, this payload has a root element. Why does file receiver create empty output file with zero byte size in the target directory?  Example of such a payload generated from mapping is as follows:                                                           
    <?xml version="1.0" encoding="UTF-8"?>                          
    <ns1:test xmlns:ns1="http://abcd.com/ab"></ns1:test>
    solution :
    If the message payload is empty (i.e., zero bytes in size), then File adapter's empty message handling feature does NOT write files into the target directory. On the other hand, if the payload is a valid XML document (as shown in example) that is generated from mapping with just a root element in it, the File Adapter does not treat it as an empty message and accordingly it writes to the target directory. To achieve your objective of not writing files (that have just a single root element) into the target directory, following could be done:
    Using a Java or ABAP Mapping in order to restrict the creation of node itself during mapping. (This cannot be achieved via Message Mapping)
    Using standard adapter modules to do content conversion first and then write file. 
    can someone help with java mapping that can be used in this case?

    Hi,
        You have not mentioned the version of PI you are working in. In case you are working with PI 7.1 or above then here is the java mapping code you need to add after message mapping in the same interface mapping
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    public class RemoveRootNode extends AbstractTransformation{
         public void execute(InputStream in, OutputStream out)
         throws StreamTransformationException {
    // TODO Auto-generated method stub
    try
         DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
         DocumentBuilder builderel=factory.newDocumentBuilder();
         /*input document in form of XML*/
         Document docIn=builderel.parse(in);
         /*document after parsing*/
         Document docOut=builderel.newDocument();
         TransformerFactory tf=TransformerFactory.newInstance();
         Transformer transform=tf.newTransformer();
         if(docIn.getDocumentElement().hasChildNodes())
              docOut.appendChild(docOut.importNode(docIn.getDocumentElement(),true));
              transform.transform(new DOMSource(docOut), new StreamResult(out));
         else
              out.write(null);
    catch(Exception e)
    public void setParameter(Map arg0) {
    // TODO Auto-generated method stub
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    try{
         RemoveRootNode genFormat=new RemoveRootNode();
         FileInputStream in=new FileInputStream("C:\\apps\\sdn\\rootNode.xml");
         FileOutputStream out=new FileOutputStream("C:\\apps\\sdn\\rootNode1.xml");
         genFormat.execute(in,out);
         catch(Exception e)
         e.printStackTrace();
    public void transform(TransformationInput arg0, TransformationOutput arg1)
              throws StreamTransformationException {
         // TODO Auto-generated method stub
         this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream());
    In case you are working in PI 7.0 you can use this code
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    public class RemoveRootNode implements StreamTransformation{
         public void execute(InputStream in, OutputStream out)
         throws StreamTransformationException {
    // TODO Auto-generated method stub
    try
         DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
         DocumentBuilder builderel=factory.newDocumentBuilder();
         /*input document in form of XML*/
         Document docIn=builderel.parse(in);
         /*document after parsing*/
         Document docOut=builderel.newDocument();
         TransformerFactory tf=TransformerFactory.newInstance();
         Transformer transform=tf.newTransformer();
         if(docIn.getDocumentElement().hasChildNodes())
              docOut.appendChild(docOut.importNode(docIn.getDocumentElement(),true));
              transform.transform(new DOMSource(docOut), new StreamResult(out));
         else
              out.write(null);
    catch(Exception e)
    public void setParameter(Map arg0) {
    // TODO Auto-generated method stub
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    try{
         RemoveRootNode genFormat=new RemoveRootNode();
         FileInputStream in=new FileInputStream("C:\\apps\\sdn\\rootNode.xml");
         FileOutputStream out=new FileOutputStream("C:\\apps\\sdn\\rootNode1.xml");
         genFormat.execute(in,out);
         catch(Exception e)
         e.printStackTrace();
    The code for PI 7.0 should also work for PI 7.1 provided you use the right jar files for compilation, but vice-versa is not true.
    Could you please let us know if this code was useful to you or not?
    Regards
    Anupam
    Edited by: anupamsap on Dec 15, 2011 9:43 AM

  • I want to read and assign value of ADF Table rows  with Java Script

    Hi,
    I want to read and assign value of ADF Table rows with Java Script, but I cant true index of current row , so I assign wrong value to anathor column of ADF Table.
    My Code;
    ADF Table items
    <af:column sortProperty="Adet" sortable="false"
    headerText="#{bindings.RezervasyonWithParams1voHarcamaOdeme1.labels.Adet}"
    binding="#{backing_ucret.column2}" id="column2">
    <af:inputText value="#{row.Adet}"
    required="#{bindings.RezervasyonWithParams1voHarcamaOdeme1.attrDefs.Adet.mandatory}"
    columns="10"
    binding="#{backing_ucret.inputText2}"
    id="inputText2" onchange="getTutar('#{bindings.voHarcamaOdeme1Iterator.rangeStart + bindings.voHarcamaOdeme1Iterator.currentRowIndexInRange + 1}','#{bindings.voHarcamaOdeme1Iterator.estimatedRowCount}','#{row.index}')">
    <f:convertNumber groupingUsed="false"
    pattern="#{bindings.RezervasyonWithParams1voHarcamaOdeme1.formats.Adet}"/>
    </af:inputText>
    </af:column>
    MY JAVA SCRIPT CODE
    <f:verbatim>
    <script language="javascript" type="text/javascript">
    function getTutar(rowkey,totalrow,currentRow){
    alert('rowkey--totalRow--currentRow-->'+rowkey+'--'+totalrow+'--'+currentRow);
    if (currentRow==0) {
    rowkey=totalrow-1;
    }else{
    var rw=totalrow-currentRow-1;
    rowkey=rw;
    alert(document.getElementById('form1:table1:'+rowkey+':inputText8').value);
    alert(document.getElementById('form1:table1:'+currentRow+':inputText8').value);
    var birim_ucret=document.getElementById('form1:table1:'+rowkey+':inputText8').value;
    var adet=document.getElementById('form1:table1:'+rowkey+':inputText2').value;
    document.getElementById('form1:table1:'+rowkey+':inputText3').value=birim_ucret*adet;
    document.getElementById('form1:inputText6').value=0;
    var t;
    var toplam=0;
    alert('before Sum');
    for (var i=0;i!=totalrow-1;i++){
    t = document.getElementById('form1:table1:'+i+':inputText3');
    toplam+=t.value*1;
    document.getElementById('form1:inputText6').value=toplam;
    </script>
    </f:verbatim>

    You can achieve the use case you describe with partial page rendering (PPR), a feature of the ADF Faces framework. Here are a few posts that achieve an interactive behavior using PPR. Off the top of my head I do not know of an exact example, but this should be a good starting point:
    http://thepeninsulasedge.com/blog/2006/09/12/adf-faces-aftableselectmany/
    http://thepeninsulasedge.com/blog/2006/08/31/adf-faces-working-with-aftableselectone-and-the-dialog-framework/
    --RiC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Coding to send mail but body with java script

    Hi,
    here my requirement is send mail in action but body with java script just tell me how i include java script in coding of mail sending.
    regards,
    ss

    self

  • Help needed :- Regarding multi prompts usage in FF3.0* with java script

    Hey i used the java script given in link :- http://sranka.wordpress.com/2008/11/09/how-to-replace-multi-go-button-prompt-by-one/#comment-96
    to hide multi-go-button in prompts and it works for IE 7 and firefox 2.0* with 10.3.4.1.
    Now since 10.1.3.4.1 is certified with firefox 3.0* ,when i use this same script in firefox 3.0* for my prompts it doesn’t work .
    Any idea why ? Please help me with this,as i want to use this hide go button feature in firefox 3.0* too.
    Are these scripts browser to browser incompatible ? If yes from where can i get the script for firefox 3.0* ?
    Awaiting for the inputs.
    Thanks,
    Nisha

    Quadruple-posting your issue won't get it resolved quicker. Please stop that. If you feel your thread needs to be on top, bump it by adding a "Any input?" post to it or something. Ome would assume that forums are around long enough for this trick to be known.

  • NEED a java coder to help with a script for a programs of mine.

    I play a game, very competitively, and need someone to make and compile a script for me. I am willing to pay upwards of 100 USD for this script made to MY standards. There will be a lot of work involved...Probably 12 hours studying my game and the purpose of the script(s). I will be buying 2-3 scripts, at roughly 50-100 USD each, depending on the quality. I will transfer the money via paypal, or other means if we can reach an agreement.
    Please IM me at Chadtrapier on AIM or send an email to [email protected]
    Or...Add me on MSN - [email protected]
    We can reach an agreement with these scripts...
    Thank you, I will also check this thread, so reply if you would like.
    ~Chad

    Ummm. Do you think that's a lot of money or something? Think in the range of 40-60 per hour. And if you're talking about warcraft I don't think they java hooks to make bots. I think you need to figure out what your problem is first and maybe learn to code them yourself.

Maybe you are looking for

  • Read one word at a time from a text file

    I want to read one word at a time from a text file as it is done by "scanf &s" function in text based programme. It is not possible by " read from text"  function. Suggest me  function or method to solve this.

  • HT201317 How do I include all photos in photo stream on Apple TV?

    I can only see photo stream photos as of march 19, but I have them from a year ago.  How do I get them to photo stream on my Apple TV?  They are on my iPad under photo stream

  • Help with removing Payment information...

    For a while, my itunes account has been telling me there's a problem with my credit card (the credit card that's on their now doesn't exist anymore). So, I decided to just not put any payment information there at all. However, there's no option for "

  • Desperate For New Features

    Are there any new features coming for Muse? It's good but when I see the online web design sites i.e. Squarespace and WIX, I'm beginning to wonder about the feasibility of having Muse CC at a higher cost. It would be good to be able to embed apps and

  • BAPI to update data in KNA1 and ADR* tables

    Hi, I have to change customer data via BAPI. I'm searching for a BAPI that updates KNA1 and ADR* tables. (so that data will be coherent). I found BAPI_CUSTOMER_CHANGEFROMDATA1 but it seems to only update KNA1 and BAPI_ADDRESSORG_CHANGE that only upda