Error using java and javascript

I have a jsp page that links to a bean and is working fine (getting data from the database).
On a html form I have a button with a picture that fires off javascript when clicked:
<BUTTON TYPE=reset onclick=showinfo('<%=index%>')>
<IMG SRC="http://localhost:8080/Portal/Images/q2.bmp" ALT="Info">
</BUTTON>
The javascript function just opens a new window and displays the text sent in:
<Script Language=JavaScript>
function showinfo(arrayindex)
InfoWin=window.open("","InfoWin","width=345,height=220");
InfoWin.document.write(arrayindex);
return false;
</Script>
Well in the above example index is a number (pulled from the database using a java bean and javascript converts it into a string then the function displays it correctly. If I replace <%=index%> with regular text it works fine as well(because java isn't used to pull data)! The problem occurs when I retrieve text data from the database and send it to the function. The web page gives errors about a nonterminating string. But I can move the code to somewhere else on the form(as long as I don't send it to java script) and it will print the text to the screen. I can also view the source of the web page and the html shows the text from the data base as if I hard coded the text into the javascript!!!!!!!!!!!!!!!!!
This must be a bug between java and javascript!
-can pass numbers(from a database) between the two
-can't pass text (from a database)between the two
Any info would help!

Found the problem myself!
I am using an odbc connection to msaccess and the spaces in the text was messing things up!
After taking out the spaces it worked again.

Similar Messages

  • What's the difference between java and Javascript?

    I a new programer, I am getting Java down. Now I want to add some java scripts to my site. Is there any difference between java and Javascript? Can I use the Java API site refference and classes? Thanks..

    Java is a programming language, Javascript is more for web pages. It is used to add interactivity to your web pages. 2 different languages.
    check out www.java.sun.com for Sun Java stuff.
    Lynn

  • Java and javascript cookies

    Hi
    i create a cookie called "SaveState" from javascript in my JSP dynpage.
    I want to read this from java (NOT JAVASCRIPT).
    Is this possible?
    if not, is there some kind of portal memory I can use to pass values between java and javascript?
    thanks
    Anton Kruse

    Hi,
    <b>Domain</b>
    The "domain" parameter is used to set the domain the cookie is accessable to. A path can be set for your own domain only and the domain path must include at least two periods (.domain.com). It must match your server's domain name. Therefore cookies are not a security risk since only the server that sets them can use them.
    Check this to know more about cookies:
    http://www.comptechdoc.org/independent/web/cgi/javamanual/javacookie.html
    If you still have questions, I will suggest to google on cookies.
    Greetings,
    Praveen Gudapati

  • PMML Export using Java and ODM 10.2

    I'm attempting to export a model I've built in ODM using Java and the example code in dmexpimpdemo.java. I'm getting an error when trying to set an additional attribute to export the data as PMML.
    exportTask.setFormat(ImportExportFormat.PMML2_1);
    If I call this method (with any ImportExportFormat) I get the exception:
    javax.datamining.JDMUnsupportedFeatureException: Unsupported ExportTask for PMML2_1
    What is the proper way to export a model as PMML using the JAVA APIs?

    PMML Export is not supported by the ODM 10.2. Hence you see unsupported exception.
    ODM 10.2 supports only Oracle native format support for the mining model export and import. For more details about the usage refer to the demo program dmexpimpdemo.java.
    To download sample programs from OTN http://www.oracle.com/technology/products/bi/odm/samples/odm_sample_code_0805.zip
    For decision tree model you can export the model details in PMML format using the DBMS_DATA_MINING.get_model_details_xml. For example, the following query returns the PMML format decision tree model as an Oracle Database XMLType
    select dbms_data_mining.get_model_details_xml('TREE_MODEL').extract('/') AS DT_DETAILS FROM dual
    Regards
    Sunil

  • Want To create Zip file  using java,And Unzip without Java Program

    I want to create a zip text file using java, I know Using ZipOutputStream , we can create a zip file, , But i want to open that zip file without java program. suppose i use ZipOutputStream , then zip file is created But for unZip also difftrent program require. We cant open that zip file without writing diff java program.
    Actually i have one text file of big size want to create zip file using java , and unzip simply without java program.Its Possible??
    Here is one answer But I want to open that file normal way(
    For Exp. using winzip we can create a zip file and also open simply)
    http://forum.java.sun.com/thread.jspa?threadID=5182691&tstart=0

    Thanks for your Reply,
    I m creating a zip file using this program, Zip file Created successfully But when im trying to open .zip file i m getting error like "Canot open a zip file, it does not appear to be valid Archive"
    import java.io.*;
    import java.util.zip.*;
    public class ZipFileCreation
         public static void main (String argv[])
         try {
         FileOutputStream fos = new FileOutputStream ( "c:/a.zip" );
         ZipOutputStream zip = new ZipOutputStream ( fos );
         zip.setLevel( 9 );
         zip.setMethod( ZipOutputStream.DEFLATED );
    //     get the element file we are going to add, using slashes in name.
         String elementName = "c:/kalpesh/GetSigRoleInfo092702828.txt";
         File elementFile = new File ( elementName );
    //     create the entry
         ZipEntry entry = new ZipEntry( elementName );
         entry.setTime( elementFile.lastModified() );
    //     read contents of file we are going to put in the zip
         int fileLength = (int)elementFile.length();
         System.out.println("fileLength = " +fileLength);
         FileInputStream fis = new FileInputStream ( elementFile );
         byte[] wholeFile = new byte [fileLength];
         int bytesRead = fis.read( wholeFile , 0 /* offset */ , fileLength );
    //     checking bytesRead not shown.
         fis.close();
    //     no need to setCRC, or setSize as they are computed automatically.
         zip.putNextEntry( entry );
    //     write the contents into the zip element
         zip.write( wholeFile , 0, fileLength );
         zip.closeEntry(); System.out.println("Completed");
    //     close the entire zip
         catch(Exception e) {
    e.printStackTrace();
    }

  • Using CSS and Javascript to display a div with flash in it, mozilla reloads the flash file!

    I am using CSS and Javascript to display a div with an
    embedded flash object in it. Mozilla Firefox reloads the flash file
    when the div is displayed! (I dont want this to happen, as it's
    unexpected functionality, my expectation would be that the flash
    file would not change it's state at all, and would remain in
    whatever state it was left in.)
    I was wondering if anyone has come across this issue and is
    there something I can do to prevent this from occurring?
    To be more specific, I have a single HTML page with 8 flash
    files embedded in it (yeah I know, it's a bit much). I am then
    using CSS and Javascript to display (via a numbered link (with an
    id)) an equivalent numbered div tag containing the flash file.
    Mozilla Firefox reloads the flash object that is in the div.
    Internet Explorer will not do this and will instead, load the flash
    object only upon initial view of the flash object. All subsequent
    links (in IE) will NOT reload the flash object on the page. I'm
    guessing this is some kind of difference in the flash player as an
    Active X object and the plugin, or is it just IE being clever? Or
    am I way off?
    Anyway, here is the code...

    I am using CSS and Javascript to display a div with an
    embedded flash object in it. Mozilla Firefox reloads the flash file
    when the div is displayed! (I dont want this to happen, as it's
    unexpected functionality, my expectation would be that the flash
    file would not change it's state at all, and would remain in
    whatever state it was left in.)
    I was wondering if anyone has come across this issue and is
    there something I can do to prevent this from occurring?
    To be more specific, I have a single HTML page with 8 flash
    files embedded in it (yeah I know, it's a bit much). I am then
    using CSS and Javascript to display (via a numbered link (with an
    id)) an equivalent numbered div tag containing the flash file.
    Mozilla Firefox reloads the flash object that is in the div.
    Internet Explorer will not do this and will instead, load the flash
    object only upon initial view of the flash object. All subsequent
    links (in IE) will NOT reload the flash object on the page. I'm
    guessing this is some kind of difference in the flash player as an
    Active X object and the plugin, or is it just IE being clever? Or
    am I way off?
    Anyway, here is the code...

  • Sending udp packets using java and receiving it using c

    hi,
    Is it possible to send udp packets using java and receive the same using c??????? if yes.... plz help immediately.

    The biggest issue is data format. The JVM is big endian, with 16-bit characters. The machine running 'C' could be almost anything. A (signed!) byte array is probably the easiest unit of exchange.
    The Java program has its own techniques for storing/retrieving data to/from the byte array - and the C program has its own techniques. ASCII Strings are often the easiest to exchange - just convert the java String objects to byte array and send them.
    apaliwal1 has already given the UDP calls to send/receive the data.

  • Difference between using Java and Non-Java in Webi.

    Hi ,
    I have one more question requesting for an answer.
    Would like to know what is the Difference between using Java and Non-Java in Webi.
    Thank You in advance.
    Appana Ganesh.

    Hi,
    check the Information in following post, the differences are discussed there:
    http://scn.sap.com/thread/3295306
    best regards,
    Victor

  • Syntax errors using sql and java

    Could somebody inform of the correct syntax for using UPDATE and INSERT SQL commands in a java program? Any information I can find demonstrates this with:
    INSERT INTO table_name(column_name, ..., column_name)
    VALUES(value, ..., value)
    However - this isn't working? any suggestions - and I know its very basic, but I'm just learning.
    String query = " INSERT INTO SESSIONS (" +                                   
                        "id,module_name, module_number, level, session " +
                        "term, class_list, location, lecturer" + ")
    VALUES('"+
                        fields.id.getText() + "', '"+
                        fields.module_name.getText() + "', '" + fields.module_number.getText() + "', '" +
                   fields.level.getText() + "', '" fields.session.getText() "', '" +
                   fields.term.getText() + "', '" fields.class_list.getText() "', '" +
                   fields.location.getText() + "', '" fields.lecturer.getText() "')";
              output.append( " \nSending query: " + connection.nativeSQL(query)+ "\n");                                                                                                         
              output.append( "query sent");     
    thanks
              int result = statement.executeUpdate(query);                    

    With all those quotes and apostrophes and string concatenations, I'd be surprised if you got it right by the fourth try. (By the way, you appear to have missed a comma between "session" and "term".) Are you planning to insert more than one record in your program? If so, you should consider using a PreparedStatement. This will likely run faster, and your program will definitely be easier to read. Also, you won't have to come back here later to ask how you deal with data that includes apostrophes (the notorious "O'Brien" problem). Here's how you do that... you define the PreparedStatement only once:
    String query =
      "INSERT INTO SESSIONS (id,module_name, module_number, level, session, term, class_list, location, lecturer) " +
      "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)";
    PreparedStatement insert = connection.prepareStatement(query);and then every time you want to insert a record you do this:
    insert.setString(1, fields.id.getText());
    insert.setString(2, fields.module_name.getText());
    // and so on...
    insert.executeQuery();

  • Java and Javascript together?

    I am a moderately new Java programmer and I was wondering if anyone knew how to use java to connect to the internet then access a Javascript function on that page. Any help would be greatly appreciated.

    Unless it's necessary, you could use the validate in the ActionFormBean of using struts instead of the Javascript. You will have to create a methode called validate of the type ActionError. You should look into the Struts example Application, they do a simple Validation on the User name and password. This is how I'm doing the validation using struts.
    It return any message that you put in your applicationRessource.properties file back to where you put the tag <html:error/> in you jsp/Struts page. It does the validation before it it execute the action. It's kinda cool, plus you don't have those anoying alert popup windows that way.
    good luck

  • Using facelets and javascript in dynamic regions

    Hello
    I'm using JDeveloper 11g 11.1.1.4.0.
    In the JDeveloper's documentation I found that there is the best parctice to use facelets.
    Now, I have next problem.
    I use dynamic region iside xhtml (facelets) page. Inside that dynamic region there is a view (jsff).
    The problem is that I can't use any custom JavaScript in that jsff.
    I tried next thing:
                <trh:script id="trhs1">
                    <af:resource type="javascript">
                      testm = function (event) {
                      alert('qqq');
                    </af:resource>
               </trh:script>
    <af:clientListener method="testm" type="dblClick"/>If that task-flow is placed inside jspx (not facelets) page, then all works.
    If that task-flow is placed inside xhtm (facelets) page, I have an error from browser that javascript's 'testm' method is not defined.
    I checked source code of the result html-page, and my javascript code really doesn't exists there.
    I can fix it by moving javascript code from the taskflow's jsff to surrounding xhtml page or using jspx page, but, maybe, there is another solution?
    Anatolii
    Edited by: Anatolii. on 11/4/2011 0:32

    Thank for replay, Shay
    I found that in Web User Interface Developer's Guide for Oracle ADF, 2 Getting Started with ADF Faces, Section 2.4, "Creating a View Page":
    Best Practice: Use Facelets to take advantage of the following:
    The Facelets layer was created specifically for JSF, which results in reduced overhead and improved performance during tag compilation and execution.
    Facelets is considered the primary view definition technology in JSF 2.0.
    Some future performance enhancements will only be available with Facelets
    Now I have facelets page with dynamic region, it works.
    I've decided to use facelets because of the forthcoming JDeveloper with JSF 2.0 and for performance improvements described above.
    Do you think it's better to use jspx?
    I have not found any limitations for facelets in Web User Interface Developer's Guide for Oracle ADF and Fusion Developer's Guide for Oracle ADF
    Anatolii

  • Error using "java" command

    I've just started trying to learn java and what is really ticking me off is that I can't get my applications to run. I use the "javac" command and it works just fine so I can get applets to work but when I use "java" to run applications I get the error message:
    "Exception in thread "main" java.lang.NoClassDefFoundError: "(class name)
    I've gone back through and checked my environmental variables and paths but get the same results. I've also tried with two versions of the SDK,
    1.2.2 and 1.4.1 and I still get the same results.
    Anyone PLEASE help, I need to get farther in learning Java!

    My First Java Program (for Windows)
    Follow these steps:
    1. Download and install the Java 2 SDK
    2. Make sure your path and classpath are set correctly
    3. Type in your first program
    4. Compile your first program
    5. Run your first program
    6. Read the Java tutorial
    1. Download and install the Java 2 SDK
    Go to the Java website and download the Java 2 SDK, Standard Edition:
    http://java.sun.com/j2se/1.4.1/download.html
    NOTE: Make sure you download the SDK (leftmost column) and not just the JRE. The JRE (Java Runtime Environment) only contains the stuff necessary to run Java programs, and not the compiler and other tools you need to develop Java programs.
    After downloading, run the installation program to install the Java 2 SDK.
    2. Make sure your path and classpath are set correctly
    After installing, READ THE INSTALLATION NOTES! Lots of people get in trouble and are asking questions in the forums because they were too lazy to read and follow the installation notes. Especially, after installing the Java 2 SDK you need to add the 'bin' directory of the SDK to your PATH, otherwise you will get an error like "javac is not recognized as an internal or external command" or something similar.
    If you've installed the Java 2 SDK in C:\j2sdk1.4.1_03, add C:\j2sdk1.4.1_03\bin to the PATH. How you should do this for different versions of Windows is described in the installation notes: http://java.sun.com/j2se/1.4.1/install-windows.html
    If you are using a version of the Java 2 SDK older than 1.4, you need to add the current directory (".") to the CLASSPATH environment variable. CLASSPATH is where Java looks for *.class files (compiled Java classes). Since Java 1.4, Java looks in the current directory automatically if the CLASSPATH isn't set, so you don't need to add "." to the CLASSPATH. Again, the installation notes explain what CLASSPATH is and how you should set it.
    3. Type in your first program
    Start Notepad and type in your first program:
    public class HelloWorld {
        public static void main(String[] args) {
            System.out.println("Hello World");
    }NOTE: Java is case-sensitive. Be careful to type in the program exactly as shown above. Don't type "Helloworld" or "helloworld" or anything else.
    Save the file somewhere in a file called "HelloWorld.java". NOTE: Again, the case must be correct. Even though Windows is case-insensitive for filenames, the case must be correct, because Java is case-sensitive. Also watch out that Notepad doesn't append ".txt" to the filename (so that you end up with a file called "HelloWorld.java.txt"). To make things worse, Windows Explorer hides file extensions by default so you don't even see that the file is actually called "HelloWorld.java.txt" instead of "HelloWorld.java".
    4. Compile your first program
    Open a command prompt, CD to the directory that contains your source file and type:
    javac HelloWorld.java
    NOTE: Again, the case must be exactly right.
    If all goes well, you'll not get any error messages and a file "HelloWorld.class" is generated.
    5. Run your first program
    To run your program, type:
    java HelloWorld
    NOTE: Don't type "HelloWorld.class". You are specifying the class name here, not the filename. Ofcourse, the case is important again.
    6. Read the Java tutorial
    Go to the Java website and follow The Java Tutorial:
    http://java.sun.com/docs/books/tutorial/
    The chapter "Your First Cup of Java" also explains in detail how to start with Java.
    Jesper

  • Java and Javascript

    I am in the process of a doing my final year project. I have to make an Interactive Guide. I am going to use SQL for the database and then use Java to interact with the database. I would like advice on and if people know of any good sources on where I can find good information on how to get Java to interact with Javascript. I have looked at other interactive guide websites and found that they use Javascript but upon viewing the source code I am unable to work out how they get them to interact.
    Secondly I was wondering if I could be pointed to a good source of information or if people can pass on advice on how to create a good login system.
    Thank you.
    Tim

    msc85tjm wrote:
    I am in the process of a doing my final year project. I have to make an Interactive Guide. I am going to use SQL for the database and then use Java to interact with the database. I would like advice on and if people know of any good sources on where I can find good information on how to get Java to interact with Javascript. I have looked at other interactive guide websites and found that they use Javascript but upon viewing the source code I am unable to work out how they get them to interact.
    Secondly I was wondering if I could be pointed to a good source of information or if people can pass on advice on how to create a good login system.
    Thank you.
    TimDefine, "interact with java." Are you talking AJAX? Not too sure what you meant by that.
    And what do you mean by "good" login system. What's "good" to me may not be "good" to you. What does it need to do, how secure does it need to be, what are your implementation restrictions, etc....

  • Cannot export in TXT formate using java and getting UnknownExportFormat exc

    I am using latest jars fro java and i could create report in the following formats
    u2022 _crystalReports
    u2022 _MSWord
    u2022 _MSExcel
    u2022 _RTF
    u2022 _editableRTF
    but when i try to create in any of these formates hereunder
    u2022 _text
    u2022 _characterSeparatedValues
    u2022 _tabSeparatedText
    u2022 _XML
    i am getting the following error
    2010-05-26 10:36:25,534,,ERROR,com.crystaldecisions.reports.common Failed to load the resource 'UnknownExportFormat' from the bundle java.util.PropertyResourceBundle@39826.
    java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key UnknownExportFormat
    at java.util.ResourceBundle.getObject(ResourceBundle.java:325)
    at java.util.ResourceBundle.getString(ResourceBundle.java:285)
    at com.crystaldecisions.reports.common.CrystalResources.loadString(Unknown Source)
    at com.crystaldecisions.reports.common.CrystalResources.loadMessage(Unknown Source)
    at com.crystaldecisions.reports.common.CrystalResourcesFactory.getLocalizedMessage(Unknown Source)
    at com.crystaldecisions.reports.common.CrystalException.getLocalizedMessage(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.do(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.a(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.a(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.call(Unknown Source)
    at com.crystaldecisions.reports.common.ThreadGuard.syncExecute(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.for(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.int(Unknown Source)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
    at com.businessobjects.sdk.erom.jrc.a.a(Unknown Source)
    at com.businessobjects.sdk.erom.jrc.a.execute(Unknown Source)
    Could anybody please advise me this is not supported or if i am missing something.
    Thanks in advance

    This is expected behavior; the formats that do not work for you are unavailable in Crystal Reports for Eclipse.  To get access to those formats you will need to use the managed version of the Report Application Server API; this is available in Crystal Reports Server, Business Objects Edge and Business Objects Enterprise.

  • Query resultset to xml using java and XML schema

    Hi,
    I query data using JDBC and I want to store it to an XML file which has a well defined XML schema. I searched a lot in the forum but did not find an answer. Please guide me to create this program.
    I have managed to use JDBC to get result set but I do not know how to export is to XML using XSD and Java.
    Please help.
    Regards,
    Ravi

    I have managed to use JDBC to get result set but I do
    not know how to export is to XML using XSD and Java.Export using XSD? Schemas are for validation.
    Iterate through the result set, and build up the XML stream by creating an entry for each row.
    Another way to do it is to load the ResultSet into a Java object and serialize that to XML using something like XStream.
    %

Maybe you are looking for

  • Error: You have more than one Creative players connected. - Recovery Tool for ZEN

    My Zen 4GB cannot be turned on anymore after a failed firmware upgrade (The installation hung up). I tried to run the firmware upgrade executable file again but the player must be on. So I tried to hardware reset by switching the power slide on while

  • Men's Health Magazine app

    I've been a Men's Health fan for a long time, until now. $4.99 for the current issue with no subscription plan was insulting enough. The biggest insult is that I accidentally synced my iPad with my work machine which removed all of my apps off the iP

  • Donald Q. asks............

    I downloaded the Adobe Help Center zip file for my Photoshop Elements 4.0, but I can't find the Adobe Help Center folder that the download instructions mentions for this zip file. The download instructions said to copy the "unzipped" zip file to: Pro

  • Change datatype

    I changed the data type of column of a table, but the data model of the report keeps the previous data type of the column. How can change it to the new data type ?

  • IPHONE FOR BUSINESS

    So I talk to ATT&T my current provider and it is all cool - juts buy your IPHONE and you can transfer your number. Get onto iTunes and go to initialise - nocando. BUsiness users cannot transfer their phone numbers on ATT&T business plans. You have to