Interpreting JSP code in Java code

Hi,
     I am writing a scheduler to generate emails based on certain events.
The email body constructed using HTML. I was constructing the HTML string
for the body using string concats. Its quickly becoming untenable to
maintain the code whenever I have to make changes to email body.
I thinking of using JSP based templates. [ I have access to all the tomcat jar files in my program]
     I have following question in this context:
     Can I parse/compile the JSP file in the java code and invoke the
resultant class with my input variable's) to get a output stream?
E.g.: Lets say I have a JSP template as shown below:
<HTML>
<TABLE >
<TR>
<TD>Name:</TD>
<TD>Telephone number:</TD>
</TR>
<%
for ( int i = 0; i < input.size(); i++)
%>
<TR>
<TD>
<%=(Contacts)input.getName()%>
</TD>
<TD>
<%=(Contacts)input[i].getTelephonenumber()%>
</TD>
</TR>
<%
%>
</TABLE >
</HTML>
I want to execute the JSP with some input in my java method and get the resultant HTML string.
Is its possible to do this? Or is there a better way of doing this?
Thanks
mg

Sorry didn't read that properly.
If you are sending emails using javamail, you can specify a URL datasource:
Can't promise this code will work out of the box, but it may give a couple of ideas...
I was sending an attachment with this mail, and I've chopped that bit out.
// Create message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]"));
InternetAddress addr = new InternetAddress();
message.addRecipients(Message.RecipientType.TO, email);
message.setSubject(mailSubject);
Multipart multipart = new MimeMultipart();
// The important part - reading the body of the message from a URL.
URL url = new URL("http://urlToGenerateTheEmailAutomatically");
DataSource source = new URLDataSource(url);
BodyPart  messageBodyPart = new MimeBodyPart();
messageBodyPart.setDataHandler(new DataHandler(source));
multipart.addBodyPart(messageBodyPart);
// send message.
message.setContent(multipart);
transport.sendMessage(message, message.getAllRecipients());

Similar Messages

  • Using jsp variable in java code

    Hey guys,
    I need some help hope you guys can help me.
    I've declared a variable "error" in a jsp. how do I access this variable in the java code whice resides in the same jsp page.
    I know I can use java variable in jsp code using
    <%= sVariable %>
    where sVariable was declared in the java code. but how do I access a jsp variable in java code??
    Thanks very much in advance

    Thanks for the reply.
    This is what I want to do.
    I've declared a variable "error" using <c:catch var="error">I want to check the value of this variable and suppose if it contains XYZ (error variable will have a long string so I just want to check if it contains a specific value) I want to do step1 and if the variable of error is not XYZ I want to do step 2
    Problem is I dont know how to check if error contains the XYZ in jsp thats why I thought java code would help here.
    Can you guys suggest a better way to solve my problem.
    Thanks again

  • Is it true that JSP creates Servlet java code?

    I am working with JSP.
    My web server is tomcat.
    Is it true that JSP creates Servlet java code of JSP files when it executes? If so how can I view them?

    Yes..it is true..
    to find out..do this..
    on purpose leave a bug in ur jsp that will generate a compilation error. So in ur browser some exception will be shown.That exception message will have the clue to the java file (e.g
    error in compiling _XYZ.java).You can manually search for this file..
    (If the copilation is successful, then this java file is deleted by the server.)

  • Please help me transform this C++ code to java code....

    guys...please help me transform this C++ code to java code....please try to explain the code..thanks
    [program]
    #include <stdio.h>
    #define ALIVE 1
    #define DEAD 0
    #define SZ 33
    int stschk (int ,int );
    main()
    int s[SZ][SZ], i, j;
    for (i=0; i<sz; i++ ) s[0] = DEAD;
    for (j=0; j<sz; j++ ) s[0][j] = DEAD;
    s[0][1] = ALIVE;
    for (i=0; i<sz-1; i++) {
    for ( j=1;j<sz;j++ ) {
    s[i][j] = stschk(s[i][j-1],s[i+1][j];
    if(s[i][j-1]==ALIVE) printf("*");
    else printf(" ");
    printf("\n");
    int stschk(int s1,int s2)
    if(((s1==DEAD)&&(s2==ALIVE))||
    ((s1==ALIVE)&&(s2==DEAD))) return ALIVE;
    else return DEAD;

    Being picky, that's not C++, that's C. Standard headers in C++ dont' have .h after them, loop variables are scoped with the for, you use constants rather than #defines, etc..
    C and C++ both don't initialise arrays by default; you'd have to write an initialiser to get it to zero out the array:
        int s[sz][sz] = {};gcc will insert a call to memset to zero the array.
    If the author was assuming that the array was zeroed out, there would be no point zeroing the first row and column.
    The code reads values which haven't been initialised. If you mark such values explicitly undefined, and change the program to report an error when undefined, then you get several cases where the program makes such report.
    So either it' s a primitive random number generator (some random number generators use uninitialised memory as a source of randomness), or it's buggy, or it's processing undefined data and throwing away the result. Either way, it cannot be directly be ported to Java if the undefined values (which are limited to a small area of the ouput) are significant.

  • How to transform this pascal code into java code!

    I want to transform this pascal code into java code . Please tel me how to do it because I really don't know how to do it!
    Thanks!
    {CALCULATE HOHN-LONDON FACTORS}
    var kk:tab4;
    PROCEDURE INTENS(var kk:tab4);
    begin
    for n:=0 to nr+2 do
    begin
    kk^[1,n]:=sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1)) +lup*(yg-2);
    kk^[2,n]:= sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1))-lup*(yg-2);
    kk^[3,n]:=0.5*(kk^[1,n]*kk^[1,n]+4*(sqr(n+1)-lup*lup));
    kk^[4,n]:= 0.5*(kk^[2,n]*kk^[2,n]+4*(sqr(n+1)-lup*lup));
    kk^[5,n]:= sqrt(ldown*ldown*yd*(yd-4)+4*sqr(n+1)) +ldown*(yd-2);
    end;
    end;
    BEGIN
    new (kk);
    intens(kk);
    writeln(f2,' ','N ','V','branch ','H-L');
    for n:=1 to np do
    begin
    fp1[n,v]:=(n-ldown)*(n+ldown+1)*sqr(kk^[2,n-1]*kk^[6,n]+4*(n+ldown)*(n-ldown+1));
    fp1[n,v]:=fp1[n,v]/(4*(n+0.5)*kk^[4,n-1]*kk^[8,n]) ;
    writeln(f2,' ',n,' ',v,' fp1 ',fp1[n,v]:10:2);
    end;
    for n:=1 to nq do
    begin
    fq1[n,v]:=sqr(kk^[2,n]*kk^[6,n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)) ;
    fq1[n,v]:=fq1[n,v]/(2*(n+0.5)*kk^[4,n]*kk^[8,n]*(n+1.5));
    fq1[n,v]:=fq1[n,v]*(n+1);
    writeln(f2,' ',n,' ',v,' fq1 ',fq1[n,v]:10:2);
    end;
    for n:=1 to nr do
    begin
    fr1[n,v]:=sqr(kk^[2,n+1]*kk^[6,n]+4*(n-ldown+2)*(n+ldown+1));
    fr1[n,v]:=fr1[n,v]/(4*kk^[4,n+1]*kk^[8,n]*(n+1.5));
    fr1[n,v]:=fr1[n,v]*(n-ldown+1)*(n+ldown+2) ;
    writeln(f2,' ',n,' ',v,' fr1 ',fr1[n,v]:10:2);
    end;

    Basically it looks like this:
    public class KK{
         private your_type[][] kk = new your_type[length][length];
         private void intens(your_type[] kk){
              for(int n= 0; n<nr+2; n++){
                   kk[1][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2)) +lup*(yg-2);
                   kk[2][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2))-lup*(yg-2);
                   kk[3][n] = 0.5*(kk[1][n]*kk[1][n]+4*(Math.pow((n+1), 2)-lup*lup));
                   kk[4][n] = 0.5*(kk[2][n]*kk[2][n]+4*(Math.pow((n+1), 2)-lup*lup));
                   kk[5][n] = Math.sqrt(ldown*ldown*yd*(yd-4)+4*Math.pow((n+1), 2)) +ldown*(yd-2);
         public static void main(String args[]){
              KK k = new KK();
              k.intens(kk);
              System.out.println(f2  + ' ' + 'N ' + 'V' + 'branch ' + 'H-L');
              for(int n=1; n < np; n++){
                   fp1[n][v] = (n-ldown)*(n+ldown+1)*Math.pow((kk[2][n-1]*kk[6][n]+4*(n+ldown)*(n-ldown+1)), 2);
                   fp1[n][v] = fp1[n][v]/(4*(n+0.5)*kk[4][n-1]*kk[8][n]) ;
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fp1 ' + fp1[n][v]:10:2);
              for(int n=1; n< nq;n++){
                   fq1[n][v] = Math.pow((kk[2][n]*kk[6][n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)), 2);
                   fq1[n][v] = fq1[n][v]/(2*(n+0.5)*kk[4][n]*kk[8][n]*(n+1.5));
                   fq1[n][v] = fq1[n][v]*(n+1);
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fq1 ' + fq1[n][v]:10:2);
              for(int n=1; n < nr; n++){
                   fr1[n][v] = Math.pow((kk[2][n+1]*kk[6][n]+4*(n-ldown+2)*(n+ldown+1)), 2);
                   fr1[n][v] = fr1[n][v]/(4*kk[4][n+1]*kk[8][n]*(n+1.5));
                   fr1[n][v] = fr1[n][v]*(n-ldown+1)*(n+ldown+2) ;
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fr1 ' + fr1[n][v]:10:2); //fr1[n][v]:10:2 --> Here you must use the BigDecimal class
    }I'm not very sure because my pascal knowledge is extremely "dated".
    What about the converter I told you about?

  • 3DES - Php crypto codes 2 Java codes convertion problem

    I give all php and java codes I convert one by one but I didnt get same result where is my mistake and what shall I do. Thanks for all.
    Php Code
    $key = "db9ca45ee012dcabaff193ca";
    $input = sha1("MehmetKaraman");
    $td = mcrypt_module_open('tripledes', '', 'ecb', '');
    $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
    mcrypt_generic_init($td, $key, $iv);
    $encrypted_data = mcrypt_generic($td, $input);
    mcrypt_generic_deinit($td);
    mcrypt_module_close($td);
    echo sha1(bin2hex($encrypted_data));
    Output : d7eaa53ab43683a1323cfae877a24efb4a918411
    Java Code :
    String message= “MehmetKaraman”;
    byte[] input = MessageDigest.getInstance("SHA1").digest(message.getBytes("utf-8"));
         final Cipher cipher = Cipher.getInstance("DESede/ECB/NoPadding");
         final SecretKey key = new SecretKeySpec("db9ca45ee012dcabaff193ca".getBytes("utf-8"), "DESede");
    cipher.init(Cipher.ENCRYPT_MODE, key );
    if( input.length % 8 != 0){
         byte [] in2 = new byte[input.length+ 8- input.length%8];
         for(int i = 0;i<input.length;i++){
         in2=input[i];
         input = in2;
         final byte[] encrypted_data = cipher.doFinal(input);
         System.out.println(bin2hex(MessageDigest.getInstance("SHA1").digest(bin2hex(encrypted_data).getBytes())));
    Output : 626b61642ec4ba8f7467933832619d492a6fdde1

    Either you need$input = sha1("MehmetKaraman", true);or in your Java you need to hex encode your sha1 digest before encrypting. When I do either of these and emulate your Java bin2hex() method I get a match.
    I don't understand why people seem unable to do simple debugging. If you had read the PHP documentation for the sha1() function and had printed out the results at each stage it would have been obvious.
    P.S. The zero padding implemented by your codeif( input.length % 8 != 0){
    byte [] in2 = new byte[input.length+ 8- input.length%8];
    for(int i = 0;i<input.length;i++){
    in2=input[i];
    input = in2;
    }can be replaced by 1 line using one of the methods in class java.util.Arrays.
    Edited by: sabre150 on Sep 15, 2010 3:10 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Hooking up Response Codes to Java code

    Hello everyone. I have created java code for OIM 11.1.1.3.0, which essentially returns a boolean.
    This code returns true if executed without issue, it returns false if there's some issue that prevents completion.
    My question is this: How do I map the boolean return to reflect the Response code in OIM. If the code returns 'true' I want the resource to have a 'Provisioned' status, and if it returns 'false' I want the resource to have a 'Provisioning' status.
    Where do I need to go to hook up the code's return to the OIM response mapping?
    Thanks in advance!

    Ok, so I've changed my code from a boolean to a String, as you had stated earlier.
    Now it returns "Success" on success of the try-block code and "Failure" in the catch.
    I have used the Resource Workflow (Nexaweb) editor from Manage Resources in the Advanced Console and have created and linked two response codes to the user creation task. The following are the values for the two responses:
    Response Code: Success
    Response Status: C
    Response Description: The task succeeded
    Response Code: Failure
    Response Status: R
    Response Description: The task failed.
    In the 'Create User' task, under the 'Resource Status Management' tab, I have mapped Provisioned to C and Provisioning to R, but every time I attempt to provision the resource, it provisions with a 'Provisioned' status, even though the 'Failure' string was returned from the catch block (as shown in the logs)
    The only thing I can think of now is that my adapter isn't configured correctly, as I left the output variable undefined... Is that necessary to hook up in order for responses to work? It would seem logical.

  • Java Byte Code --- Normal Java Code(Text)

    I m making an application IDE(C/C++) for Java, In this I want to give Option to convert Java Byte Code to Normal Java Code(Text).........For This tell me how to do it.

    See the page
    http://java.sun.com/j2se/1.4.1/docs/tooldocs/windows/javap.html
    for a description of javap.exe, the Java class file disassembler.

  • Running Matlab code from java code

    Ok so I need to make a java gui interface to run Matlab code. After a lot of search I am aware of three approaches,the com.mathworks.jmi package, JNI and i/o streams. So as far as the first approach I cannot find that package nowhereto downlaod, so please if anyone knows where to find it, or why I cannot find it... As far as the second and third approach, I need this to run on both linux and windows so JNI is the only way. So first of all if someone has another approach to suggest, I would like to hear! So I have found code to do this but it is not working and the problem is that there is c code in all this, and my c knowledge is not good at all, so as you have probably understand this is more like a c problem than java, but I'm not completely sure. Anyway I'm posting all the code I use, then the commands I used to compile it and at last the problem.
    Engine.java
    package MatlabNativeInterface;
    import java.io.*;
    * <b>Java Engine for Matlab via Java Native Interface (JNI)</b><br>
    * This class demonstrates how to call Matlab from a Java program via
    * JNI, thereby employing Matlab as the computation engine.
    * The Matlab engine operates by running in the background as a separate
    * process from your own program.
    * <p>
    * Date: 04.04.03
    * <p>
    * Copyright (c) 2003 Andreas Klimke, Universit&#65533;t Stuttgart
    * <p>
    * Permission is hereby granted, free of charge, to any person
    * obtaining a copy of this software and associated documentation
    * files (the "Software"), to deal in the Software without
    * restriction, including without limitation the rights to use, copy,
    * modify, merge, publish, distribute, sublicense, and/or sell copies
    * of the Software, and to permit persons to whom the Software is
    * furnished to do so, subject to the following conditions:
    * <p>
    * The above copyright notice and this permission notice shall be
    * included in all copies or substantial portions of the Software.
    * <p>
    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
    * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    * OTHER DEALINGS IN THE SOFTWARE.
    * @author W. Andreas Klimke, University of Stuttgart
    *         ([email protected])
    * @version 0.1
    public class Engine {
         * Calls the function <code>engOpen</code> of Matlab's C Engine library.
         * Excerpts from the Matlab documentation:
         * "On UNIX systems, if startcmd is NULL or the empty string,
         * <code>engOpen</code> starts MATLAB on the current host using the
         * command <code>matlab</code>. If startcmd is a hostname, <code>engOpen
         * </code> starts MATLAB on the designated host by embedding the specified
         * hostname string into the larger string:
         * <code>rsh hostname \"/bin/csh -c 'setenv DISPLAY\ hostname:0; matlab'\"
         * </code>. If startcmd is any other string (has white space in it, or
         * nonalphanumeric characters), the string is executed literally to start
         * MATLAB. On Windows, the startcmd string must be NULL."<br>     
         * See the Matlab documentation, chapter "External Interfaces/API
         * Reference/C Engine Functions" for further information.
         * @param startcmd The start command string.
         * @throws IOException Thrown if starting the process was not successful.
      public native void open(String startcmd) throws IOException;
          * Calls the function <code>engClose</code> of Matlab's C Engine
          * library.     This routine allows you to quit a MATLAB engine session.
          * @throws IOException Thrown if Matlab could not be closed.
         public native void close() throws IOException;
         * Calls the function <code>engEvalString</code> of Matlab's C Engine
         * library. Evaluates the expression contained in string for the MATLAB
         * engine session previously started by <code>open</code>.
         * See the Matlab documentation, chapter "External Interfaces/API
         * Reference/C Engine Functions" for further information.
         * @param str Expression to be evaluated.
         * @throws IOException Thrown if data could not be sent to Matlab. This
         *                     may happen if Matlab is no longer running.
         * @see #open
      public native void evalString(String str) throws IOException;
          *  Reads a maximum of <code>numberOfChars</code> characters from
          * the Matlab output buffer and returns the result as String.<br>
          * If the number of available characters exceeds <code>numberOfChars</code>,
          * the additional data is discarded. The Matlab process must be opended
          * previously with <code>open()</code>.<br>
          * @return String containing the Matlab output.
          * @see #open
          * @throws IOException Thrown if data could not be received. This may
          *                     happen if Matlab is no longer running.
      public native String getOutputString(int numberOfChars);
          * Initialize the native shared library.
      static {
             System.loadLibrary("Engine");//I have changed this
         //System.loadLibrary("engineJavaMatlab");
         System.err.println("Native Matlab shared library loaded.");
    }Engine.c
    #include <jni.h>
    #include "MatlabNativeInterface_Engine.h"
    #include <stdio.h>
    #include "engine.h"
    #define DEFAULT_BUFFERSIZE 65536
    Engine* ep;
    char outputBuffer[DEFAULT_BUFFERSIZE];
    JNIEXPORT void JNICALL
    Java_MatlabNativeInterface_Engine_open(JNIEnv *env, jobject obj, const jstring startcmd) {
      const char *c_string = (*env)->GetStringUTFChars(env, startcmd, 0);
      if (!(ep = engOpen(c_string))) {
        jclass exception;
        (*env)->ReleaseStringUTFChars(env, startcmd, c_string);
        exception = (*env)->FindClass(env, "java/io/IOException");
        if (exception == 0) return;
        (*env)->ThrowNew(env, exception, "Opening Matlab failed.");
        return;
      (*env)->ReleaseStringUTFChars(env, startcmd, c_string);
         /* indicate that output should not be discarded but stored in */
         /* outputBuffer */
      engOutputBuffer(ep, outputBuffer, DEFAULT_BUFFERSIZE);
    JNIEXPORT void JNICALL
    Java_MatlabNativeInterface_Engine_close(JNIEnv *env, jobject obj) {
         if (engClose(ep) == 1) {
           jclass exception;
        exception = (*env)->FindClass(env, "java/io/IOException");
        if (exception == 0) return;
        (*env)->ThrowNew(env, exception, "Closing Matlab failed.");
        return;
    JNIEXPORT void JNICALL
    Java_MatlabNativeInterface_Engine_evalString(JNIEnv *env, jobject obj, const jstring j_string) {
      const char *c_string;
         c_string = (*env)->GetStringUTFChars(env, j_string, 0);
      if (engEvalString(ep, c_string) != 0) {
           jclass exception;
        exception = (*env)->FindClass(env, "java/io/IOException");
        if (exception == 0) return;
        (*env)->ThrowNew(env, exception, "Error while sending/receiving data.");
      (*env)->ReleaseStringUTFChars(env, j_string, c_string);
    JNIEXPORT jstring JNICALL
    Java_MatlabNativeInterface_Engine_getOutputString(JNIEnv *env, jobject obj, jint numberOfChars) {
      char *c_string;
         jstring j_string;
         if (numberOfChars > DEFAULT_BUFFERSIZE) {
              numberOfChars = DEFAULT_BUFFERSIZE;
      c_string = (char *) malloc ( sizeof(char)*(numberOfChars+1) );
         c_string[numberOfChars] = 0;
      strncpy(c_string, outputBuffer, numberOfChars);
         j_string = (*env)->NewStringUTF(env, c_string);
         free(c_string);
      return j_string;
    }MatlabNativeInterface_Engine.h (as produced by javah)
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class MatlabNativeInterface_Engine */
    #ifndef _Included_MatlabNativeInterface_Engine
    #define _Included_MatlabNativeInterface_Engine
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class:     MatlabNativeInterface_Engine
    * Method:    open
    * Signature: (Ljava/lang/String;)V
    JNIEXPORT void JNICALL Java_MatlabNativeInterface_Engine_open
      (JNIEnv *, jobject, jstring);
    * Class:     MatlabNativeInterface_Engine
    * Method:    close
    * Signature: ()V
    JNIEXPORT void JNICALL Java_MatlabNativeInterface_Engine_close
      (JNIEnv *, jobject);
    * Class:     MatlabNativeInterface_Engine
    * Method:    evalString
    * Signature: (Ljava/lang/String;)V
    JNIEXPORT void JNICALL Java_MatlabNativeInterface_Engine_evalString
      (JNIEnv *, jobject, jstring);
    * Class:     MatlabNativeInterface_Engine
    * Method:    getOutputString
    * Signature: (I)Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_MatlabNativeInterface_Engine_getOutputString
      (JNIEnv *, jobject, jint);
    #ifdef __cplusplus
    #endif
    #endifand a Main.java
    import MatlabNativeInterface.*;
    import java.io.*;
    * Demonstration program for connecting Java with Matlab using the Java
    * Native Interface (JNI). Wrapper functions access Matlab via Matlab's
    * native C Engine library.
    public class Main {
         public static void main(String[] args) {
              Engine engine = new MatlabNativeInterface.Engine();
              try {
                   // Matlab start command:
                   engine.open("matlab -nosplash -nojvm");
                   // Display output:
                   System.out.println(engine.getOutputString(500));
          // Example: Solve the system of linear equations Ax = f with
                   // Matlab's Preconditioned Conjugate Gradients method.
                   engine.evalString("A = gallery('lehmer',10);");  // Define Matrix A
                   engine.evalString("f = ones(10,1);");            // Define vector f
                   engine.evalString("pcg(A,f,1e-5)");              // Compute x
                   // Retrieve output:
                   System.out.println(engine.getOutputString(500));
                   // Close the Matlab session:
                   engine.close();
              catch (Exception e) {
                   e.printStackTrace();
    }so I compile them with:
    javac -d classes @files.txt
    javah -classpath classes MatlabNativeInterface.Engine
    cc -shared -I/usr/java/jdk1.6.0_06/include/ -I/usr/java/jdk1.6.0_06/include/linux/ -I/usr/local/share/matlab7.6/extern/include/ Engine.c -o libEngine.soso everything gets compiled well and then I run Main:
    /javas/classes/_>mv libEngine.so classes/
    /javas/classes/_>cd classes/
    /javas/classes/_>java -Djava.library.path=. Main
    Exception in thread "main" java.lang.UnsatisfiedLinkError: /javas/classes/libEngine.so: /javas/classes/libEngine.so: undefined symbol: engOpen
            at java.lang.ClassLoader$NativeLibrary.load(Native Method)
            at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676)
            at java.lang.Runtime.loadLibrary0(Runtime.java:823)
            at java.lang.System.loadLibrary(System.java:1030)
            at MatlabNativeInterface.Engine.<clinit>(Engine.java:99)
            at Main.main(Main.java:11)So... please help!

    I need this to run on both linux and windows so JNI is the only wayHuh? Streams in general work on windows and linux. So maybe some more specific info
    about what you mean by "i/o streams."
    I am aware of three approachesA fourth approach is to write an application in C which communicates with Matlab directly
    and then uses some idiom such as sockets to allow communication to java. This would generally
    be the method that I would prefer over all others since it makes debugging and testing easier.
    undefined symbol: engOpenSomehow you are missing a library (nothing specific to to with JNI nor java) in you JNI code.
    Odd error since I would normally expect something else. Try using System.load/loadLibrary() in java to explicitly load the Matlab
    library (or libraries) before your JNI library. The load/LoadLibrary calls don't care if it is JNI or not.

  • Converting CPP code into JAVA Code

    i have made a cpp file that is running fine... is ther a tool which can convert that cpp file into java file easily?

    No

  • Java code vrs JSTL

    I'm beginning to study jsp I have a knowledge in the Java language, let me know if you need to learn JSTL for JSP pages or just know java
    is more easy for me make the JSP page with java code. thanks for you answers

    981159 wrote:
    so I'm making a mistake when I'm studying JSP JSF should study?It's difficult to say if you are or not. It used to be a common question in enterprise architecture exams. When do you use JSP vs using JSF.
    These days the emphasis is on ease of development with many frameworks striving to solve as many common developer problems as they can so you can concentrate on writing only the business logic for your project. With plain JSPs you need to handle many cross cutting concerns yourself and develop filters and application controllers to deal with those concerns (otherwise you reuse by copy paste!). Because JSF (and many other frameworks) is a full MVC framework they already provide all those filters and application controllers while also improving the view with components, validation, templating and asynchronous request processing. Perhaps there are applications out there that don't need any of these, if they exist then those are the applications one could consider using plain JSPs for. It would be a shame if a developer has to take time from writing and testing business logic to developing functionality already made available by most frameworks. Also the arrival of Play! and other stateless MVC frameworks makes it even less likely that you'll find an application where an honest architecture choice process will pick JSP as most applicable.
    But your question is should you learn it? Well, there are lots of companies in the industry that have systems that use JSPs either alone or with other frameworks. Not only that but some of those companies have not changed their architecture choices to move away from it for various plausible reasons. Then there is products developed using JSP based technologies like Oracle ADF which uses JSF 1.2 (which used JSPs). If you intend to work for those companies or with those products at some point then you'll have to learn it to be most effective at your job. My suggestion was not necessarily to stop learning it, but to be aware of where JSPs stand in relation to other technologies.

  • Embedding Java Code(URGENT)

    Hello,
    I'm trying to do the following, I'm trying to embed Java code into my BPEL process, I have read the tutorial that explains how to embed a java code into BPEL(http://www.oracle.com/technology/products/ias/bpel/pdf/orabpel-Training-Segment10.pdf) but unfortunately the tutorial discusses only how to call the Entity Bean but doesnt mention where in folders(directory) should the bean itself be placed, where are the imports.
    I'm going to start with a simple example, a class called Multiplier that has function square, Here is the code for the class:
    //Java Multiplier class
    public class Multiplier{
    public Multiplier(){}
    public int square(int x){
    return x*x; }
    this is code that will be placed in the EXEC(Java code snippet):
    //Java Code Snippet goes here...
    try{
    Object input= getVariableData
    ("input","payload","/JavaCode");
    String parser= input.toString();
    int in= Integer.parseInt(parser);
    Multiplier obj1= new Multiplier();
    int result= obj1.square(in);
    addAuditTrailEntry("The square of the input is:"+result);
    catch(Exception en){
    addAuditTrailEntry(en);
    Where should the multiplier class be located(in which folder in the ecplise)or how will the BPEL refer to it ?
    Shouldnt I import the Multiplier class in the EXEC(snippet) where should that line go?
    Thanks in advance
    Hussam Galal

    After going through the Forum I saw I question similar to mine, and I found out there's an example similar to what I am trying to do at C:\orabpel\samples\references\JavaExec
    I tried to make an example almost exactly like JavaExec and I edited my build.xml to be similar to build.xml of the example but I keep getting this error:
    BUILD FAILED: C:\eclipse-SDK-3.0-win32\eclipse\workspace\Calc\build.xml:28: ORABPEL-00017
    Java compilation failed.
    Failed to compile file(s) "Calc.bpel".
    Exception reported is: Calc.bpel:44: ';' expected.
    Multiplier mult= new Multiplier();
    ^
    1 error
    Please verify that file Calc.bpel is valid java file or if all required libraries are included in your classpath.
    classpath: C:\eclipse-SDK-3.0-win32\eclipse\startup.jar;C:\eclipse-SDK-3.0-win32\eclipse\startup.jar;C:\eclipse-SDK-3.0-win32\eclipse;c:\eclipse-SDK-3.0-win32\eclipse\plugins\bpelz_0.9.10\lib\orabpel-ant.jar;c:\eclipse-SDK-3.0-win32\eclipse\plugins\bpelz_0.9.10\lib\orabpel-boot.jar;c:\eclipse-SDK-3.0-win32\eclipse\plugins\bpelz_0.9.10\lib\orabpel-common.jar;c:\eclipse-SDK-3.0-win32\eclipse\plugins\bpelz_0.9.10\lib\orabpel-thirdparty.jar;c:\eclipse-SDK-3.0-win32\eclipse\plugins\bpelz_0.9.10\lib\orabpel.jar;C:\DOCUME~1\temp_ps\LOCALS~1\Temp\bpelc40446.tmp\BPEL-INF\classes
    Here's the java code in the EXEC(snippet):
    // Java code snippet goes here ...
    com.otn.samples.javaexec.Multiplier
    Multiplier mult= new Multiplier();
    Object obj1= getVariableData("input","payload","/Calc");
    String str= obj1.toString();
    int in= Integer.parseInt(str);
    int result= mult.square(in);
    addAuditTrailEntry("The result is: "+result);
    Finally here's the my build.xml:
    <?xml version="1.0"?>
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Run cxant on this file to build, package and deploy the
    Calc BPEL process
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <project name="Calc" default="all" basedir=".">
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Name of the domain the generated BPEL suitcase will be deployed to
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
         <property name="deploy" value="default"/>
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    What version number should be used to tag the generated BPEL archive?
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <property name="rev" value="1.0"/>
         <target name="CompileJava">
         <mkdir dir="${basedir}/BPEL-INF/classes"/>
              <javac srcdir="${basedir}/src" destdir="${basedir}/BPEL-INF/classes"/>
         </target>
    <target name="Calc">
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    the bpelc task compiles and package BPEL processes into versioned BPEL
    archives (bpel_...jar). See the "Programming BPEL" guide for more
    information on the options of this task.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <bpelc home="${home}" rev="${rev}" deploy="${deploy}"/>
    </target>
    <target name="all" depends="CompileJava, Calc"/>
    </project>

  • Migration of JAVA code(JDK 1.2) from Windows NT to Solaris 8.0

    What are the issues while porting the code in JAVA code JDK 1.1.7 and JDK 1.2 from Windows NT to Solaris 8.0
    What are the considerations while porting the scripts of installshield from windows NT to solaris 8.0

    There is no special issues about running Java code created on NT on Solaris.
    I have met only one issue in JDK 1.2, when the original code was compiled using IBM Java Compiler and it was fixed by recompile with original Java Compiler from JDK.

  • Generate IDL from Java Code, Classes, UML, etc?

    Hi,
    is is possible to generate IDL code from Java Code, Classes, UML, ... using JDeveloper?
    I know this is somewhat reverse engeneering, but it would speed up the migration of our existing Java project...
    Thanks,
    Johan

    Hi,
    is is possible to generate IDL code from Java Code, Classes, UML, ... using JDeveloper?
    I know this is somewhat reverse engeneering, but it would speed up the migration of our existing Java project...Unfortunately it does not. The IDL to Java conversion is handled under the covers by the idl2java.exe included with the database. You might want to search on google for a IDL generator from java source.
    java2iiop (another tool) just generates IIOP stubs from classes and interfaces, but I don't think it creates IDL.
    Rob

  • Test.jsp not able to display the output from the java code.

    when i try to invoke http://localhost/papz/test.jsp
    I dont see anything. The page is blank. And there are no error messages in any log files. When i click on view source in IE i get to see the entire source code, including the jave code.
    <html>
    <head>
    <title>Test</title>
    <body>
    <%
    out.println("Hello World");
    %>
    asdfasdfasdf
    </body>
    </html>
    i added in the asdfasdf to see whehter it will be printed or not... It does print that stuff out.
    when i try to invoke the login.jsp page, i get the dialog box "save this file to disk"
    Any clues whats going on...?
    I followed the instructions...over and over again... but it doesnt seem to help.
    win nt 4.0
    apache 1.3.12
    jserv 1.1.1
    Pls help. Thanks

    Hi,
    Have you solved your problem?
    I4m trying to do the same, but I installed portal 30, then portal to go, and when I try to run test.jsp I get the following error:
    Request URI:/papz/test.jsp
    Exception:
    java.lang.NoSuchMethodError: oracle.jsp.util.JspUtil: method
    stripTarget(Ljava/lang/String;C)Ljava/lang/String; not found
    Thanks
    Pablo Lopera
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by NewBie:
    when i try to invoke http://localhost/papz/test.jsp
    I dont see anything. The page is blank. And there are no error messages in any log files. When i click on view source in IE i get to see the entire source code, including the jave code.
    <html>
    <head>
    <title>Test</title>
    <body>
    <%
    out.println("Hello World");
    %>
    asdfasdfasdf
    </body>
    </html>
    i added in the asdfasdf to see whehter it will be printed or not... It does print that stuff out.
    when i try to invoke the login.jsp page, i get the dialog box "save this file to disk"
    Any clues whats going on...?
    I followed the instructions...over and over again... but it doesnt seem to help.
    win nt 4.0
    apache 1.3.12
    jserv 1.1.1
    Pls help. Thanks<HR></BLOCKQUOTE>
    null

Maybe you are looking for

  • Premier cs5 crashes on opening titler

    Hi, We have a HPz8000 running win7 64bit with a FX3800 nvidia card and cs5 production premium and a matrox mxo2 max. Each time you open the titler the program crashes. We have reinstalled premier same thing happens. we have uninstalled mxo2 it still

  • Instance crashing with ORA-00469: CKPT process terminated with error

    Hi, Instance crashing with ORA-00469: CKPT process terminated with error on 10.2.0.4. Any possibe causes? Thanks, Madhav

  • While loading portlet....?????

    Hi I m new to portals concept, I am working on developing portals using jetspeed, i want to know that when we click on a link and open a new portlet then does the whole page gets loaded(ie other portlet get reloaded or not) coz of asking this questio

  • How to report outage

    Imessage suddenly stopped working responding that every phone number was unregisterd.  These are numbers that I imessage daily, like my wife and best friend.  How do I report this outage to apple?

  • Help me with Report Application Server SDK

    Please, I need help with Report Application Server SDK. public static void rpt2xml(ReportClientDocument rcd) { IXMLExportFormat xmlExportFormat = new XMLExportFormat(); XMLExportFormats xmlExportFormats = new XMLExportFormats(); IXMLExportFormatOptio