If I use "JSP - Java - JNI" ??

When the Java -> JNI -> C is writen and tested OK.
How can I use JSP to import the Class into JSP page???
I tried. But failure.
Have someone show a sample?? help~ Q_Q

Thanks you again... ^_^ to help
All My step and files are shown below:
--[1 step]--------[ JSP file ]--------------------------
<jsp:useBean id="myBean" scope="page" class="Counter"/>
<jsp:getProperty name="myBean" property="count"/>
--[2 step]---------[ write JavaBean ]-----------------
public class Counter{
public Counter(){}
public native String printt(); // It's Native entry
public static void main(String[] args){ // This just for Java in DOS runable.
new Counter().printt();
public String getCount(){
return(new Counter().printt());
@@@@@@@@@@@@@@@@ <= the server will call getCount() method, which the DLL's create the printt() method.it may cause the 1st errors because can't find printt().I guess.
public void setCount(int newCount){}
static{
System.loadLibrary("HelloWorld"); //LOAD the DLL's from C create
---[3 step]------ [ Create Counter.h ] -- CMD:[ javah - jni Counter ]---------
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Counter */
#ifndef IncludedCounter
#define IncludedCounter
#ifdef __cplusplus
extern "C" {
#endif
* Class: Counter
* Method: printt
* Signature: ()Ljava/lang/String;
JNIEXPORT jstring JNICALL Java_Counter_printt
(JNIEnv *, jobject);
#ifdef __cplusplus
#endif
#endif
----[4 step]--- [Write HelloWorld.c ]-------------
#include <jni.h>
#include <stdio.h>
#include "Counter.h"
JNIEXPORT jstring JNICALL
Java_Counter_printt(JNIEnv *env,jobject this){
printf("Hello World!\n hihihi success!");
return;
---[5 step]-- [use VC++ 5 to create the DLL from HelloWorld.c ]
---[6 step] ----- The result that Server says -------
500 Internal Server Error
java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
...

Similar Messages

  • How to create two level dynamic list using JSP , Java Script and Oracle

    I am new in JSP. And i am facing problem in creating two level dynamic list using JSP ,Java Script where the listdata will come from Oracle 10g express edition database. Is there any easy way in JSP that is available on in ASP.NET.
    Plz response with details.

    1) Learn JDBC API [http://java.sun.com/docs/books/tutorial/jdbc/index.html].
    2) Create DAO class which contains JDBC code and do all SQL queries and returns or takes ID's or DTO objects.
    3) Learn Servlet API [http://java.sun.com/javaee/5/docs/tutorial/doc/].
    4) Create Servlet class which calls the DAO class, gets the list of DTO's as result, puts it as a request attribute and forwards the request to a JSP page.
    5) Learn JSP and JSTL [http://java.sun.com/javaee/5/docs/tutorial/doc/]. Also learn HTML if you even don't know it.
    6) Create JSP page which uses the JSTL c:forEach tag to access the list of DTO's and iterate over it and prints a HTML list out.
    You don't need Javascript for this.

  • Search for a String within a document (Word, txt, doc) using JSP, JAVA

    Hi
    I have created a little application that uses combination of JSP and HTML. Users of this application can upload documents which are then stored on the server. I need to develop functionality where I can allows users to search for a string within a document. More precisely, user would type in some string in a text box and application will search all uploaded documents for that string and return the downloadable links to those documents that contains that string. I have never done this before. I was wondering if someone could get me started on this or point me to some thread where this idea is already discussed. Any Jave code exists for searching through documents??
    Thanks for your help
    Riz

    http://www.ibm.com/developerworks/java/library/j-text-searching.html
    http://en.wikipedia.org/wiki/Full_text_search
    Type these parameter in yahoo:+efficient text search
    you will need something like openoffice library to read microsoft word document.

  • Using JSP / Java to write/create an xml file

    I have been looking around the internet and in my books and I cannot find a good example of JAVA/JSP writing an XML file. I already have a recursive method that will generate the xml .. what's missing in my code now is how am i goin to append or write that xml string into an existing file..
    suppose i have this xml string
    String xmlString = "<?xml version="1.0"?><txn><test>this is just a test</test></txn>";
    FileOutputStream fos = new FileOutPutStream(C://files/sample.xml);
    now , how i will write the xmlString into sample.xml file...
    Any suggestions/ ideas/ tutorial links would be deeply appreciated.. thx!

    never mind.. my code is workin now..

  • How to download a file from server machine to client machine using jsp

    Hi,
    In my application, I have an excel file stored on my server machine. How can I download that excel file on to my client machine using jsp. Is there any other way I can open that file from my machine and save it in my machine using jsp/java?
    Its an emergency for me to do this.
    Can anyone provide me the full code to download a file from server machine as I don't have
    time to browse through various sites.
    thanks in advance,
    Tiijnar

    Please post your code using code tags (click on CODE above the text area, when posting)
    response.setContentType("application/octet-stream");Why octet-stream? Set the correct mime-type.
    String disHeader = "Attachment; Filename=\"filename\"";The filename should just be the file's name. Not the complete path to the file! This will tell anyone where the file is located on the server. It's also inconvenient because by default,the browser will suggest it as the name for the download.
    Your way of writing to the output stream is just plain wrong. See this snippet (picked from [http://balusc.blogspot.com/2007/07/fileservlet.html])
            BufferedInputStream input = null;
            BufferedOutputStream output = null;
            try {
                // Open streams.
                input = new BufferedInputStream(new FileInputStream(file), DEFAULT_BUFFER_SIZE);
                output = new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);
                // Write file contents to response.
                byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
                int length;
                while ((length = input.read(buffer)) > 0) {
                    output.write(buffer, 0, length);
                // Finalize task.
                output.flush();
            } finally {
                // Gently close streams.
                close(output);
                close(input);
            }

  • JSP & Java Mail

    Hai Buddies,
    I don't know about JSP (only little bit), Iwant to create a page in jsp any one plzzz help me i will give the details about the the page ie given below..
    The page containning
    --number, name contacts, comments ,action plan,dre name,lead name
    --when i stores the above details to the database a mail is sent to the dre and the lead respectively
    --Using JSP & Java Mail                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    There is a forum on java database connectivity
    http://forum.java.sun.com/forum.jspa?forumID=48
    A forum on java mail
    http://forum.java.sun.com/forum.jspa?forumID=43
    There are loads of tutorials on the sun site and elsewhere, you need to read these and start coding. No-one is going to write this for you.
    Before posting questions use the search bar to the left, most of the questions you ask have been dealt with MANY times before, you will find code quickly using the search facility, saving you a lot of time.

  • How can i  use  this  java program to access from  a jsp page?

    import java.io.*;
    import java.util.*;
    public class FileProcessing
      //create a vector container  for the input variables
         Vector variables = new Vector();
      //create a vector container for the constants
         Vector constants = new Vector();
      /*create a string expression container for the equation
         as read from the file */
         String expression = " ";
      //create double result container for the final result
         double result = 0;
         public boolean processFile(String filename,String delim)
          //index for values vector
              int num_values = 0;
          //index for constants vector
              int num_constants = 0;
          //current line being read from the external file.
              String curline = " ";
          //start reading from the external file
              try
                   FileReader fr = new FileReader(filename);
                   BufferedReader br = new BufferedReader(fr);
                   while(true)
                        curline = br.readLine();
                        if(curline == null)
                             break;
                    //determine the type of current interaction
                        boolean variable = curline.startsWith("input");
                        boolean constant = curline.startsWith("constant");
                        boolean equation = curline.startsWith("equation");
                        boolean output = curline.startsWith("result");
                   //on input variables
                        if(variable)
                          StringTokenizer st = new StringTokenizer(curline,delim);
                          int num = st.countTokens();
                          int count=0;
                          while(st.hasMoreTokens())
                               String temp = st.nextToken();
                               if(count==1)
                                    byte b[]= new byte[100];
                                    System.out.println(temp);
                                    System.in.read(b);
                                    String inputval = (new String(b)).trim();
                                    variables.add(num_values,inputval);
                                    num_values++;
                               count++;
                        // on constant values
                        if(constant)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==1)
                                       byte b[]= new byte[100];
                                       System.out.println(temp);
                                       System.in.read(b);
                                       String cons = (new String(b)).trim();
                                       constants.add(num_constants,cons);
                                       num_constants++;
                                  count++;
                        // on equation
                        if(equation)
                             StringTokenizer st = new StringTokenizer(curline,delim);
                             int num = st.countTokens();
                             int count = 0;
                             while(st.hasMoreTokens())
                                  String temp = st.nextToken();
                                  if(count==2)
                                       this.expression = temp;
                                  count++;
              // now we are ready to evaluate the expression
                       if(output)
                          org.nfunk.jep.JEP  myparser= new org.nfunk.jep.JEP();
                          myparser.setAllowAssignment(true);
                          for(int i=1;i<variables.size()+1;i++)
                             String name = "arg"+Integer.toString(i);
                             myparser.addVariable(name,new Double(variables.get(i-1)
                                                .toString()).doubleValue());
                          for(int i=1;i<constants.size()+1;i++)
                               String name = "arg" +Integer.
                                         toString(i+variables.size());
                               myparser.addConstant(name,new Double(constants.get(i-1).toString()));
                   //output is obtained as follows
                          myparser.parseExpression(expression);
                          result = myparser.getValue();
                          System.out.println("Assay value: "+result);
              catch(Exception e)
                   System.out.println(e.toString());
              return true;
         public static void main(String[] args)
              FileProcessing fp = new FileProcessing();
              fp.processFile("input.eqn",":");
    }here i need to generate the strings like 'enter value1' and respective text boxes dynamically . i should use this java program as business logic and a jsp page for view.
    following given is my text file input.eqn
    input:enter value1:arg1
    input:enter value2:arg2
    input:enter value3:arg3
    constant:enter constant1:arg4
    constant:enter constant2:arg5
    equation:enter equation:(arg1+arg2)*(arg3+arg4)*arg5
    result:

    Why do you double post ? http://forum.java.sun.com/thread.jspa?threadID=646988&tstart=0
    Why dint that answer satisfy you ? And why dint you say so in that thread rather than posting the same question again ?
    ram.

  • Using a java variable in jsp-Reports?

    Hello everyone,
    is it possible to use a java variable in the xml-definition of a report? Something like
    <%@ taglib uri="/WEB-INF/lib/reports_tld.jar" prefix="rw" %>
    <% String someSqlStatement="select * from emp"; %>
    <rw:report id="myReport">
    <rw:objects id="myObjects">
    <report DTDVersion="9000010" name="myReport">
    <data>
    <dataSource name="Q_1">
    <select>
    <![CDATA[
    <%= someSQLStatement %>
    ]]>
    </select>
    It won't work that way (as the string is not evaluated and inserted into the definition, but how could it be done? Would be great to modify the report programatically that way? Any ideas?
    TIA,
    Marcel Jantz

    To pass values to Reports, you should use the "parameters" attribute in the <rw:report> tag. In the above case you would have:
    <% String myParameters="p_someSqlStatement=select%20*%20from%20emp"; %>
    <rw:report id="myReport" parameters="<%= myParameters %>">
    <rw:objects id="myObjects">
    <report DTDVersion="9000010" name="myReport">
    <data>
    <dataSource name="Q_1">
    <select>
    <![CDATA[ &p_someSqlStatement ]]>
    </select>
    The body of the <rw:objects> tag isn't evaluated since the Reports Builder needs to be able to open and load the <rw:objects> tag. As the Reports builder doesn't run the .jsp on open, it only parses it, the <rw:objects> tag can't have values that need to be evaluated.

  • Problem using jsp:forward in java script

    hi,
    when I use jsp forward tag inside java script i'm getting a problem that
    when the jsp is invoked it is getting forwarded to the page specified in the forward tag, without checking the if conditions. Following code may give you a better idea.
    <html>
    <script>
    function test()
    if(document.f.htemp.value=="true")
    alert("jus");
    else
    var s=document.f.htemp.value;
    alert(s);
    <jsp:forward page="success.jsp" />
    </script>
    <body>
    <form name="f" method=post>
    <input type=text name=htemp value="true">
    <input type=button onclick="test()">
    </form>
    </body>
    </html>
    please help me,thanks inadvance
    regards
    chandu

    What pgeuens means is that you can't mix javascript and jsp/java code in this way.
    ALL of the jsp/java code gets executed at the server end.
    This produces an HTML page (with embedded javascript) which gets sent to the client.
    The client then runs javascript code in response to events (onLoad, onClick, onChange etc etc)
    So in this case, the jsp:forward will always be executed, because as far as the server is concerned, the javascript is just template text.
    If you WANT to do a conditional forwarding on the server side you do it in java ie (horribly using scriptlet)
    <%
    if (testCondition){
    %>
      <jsp:forward>
    %<
    %>Or if you want to test what the client has entered client side, all you can do is submit the form, or navigate to a URL
    <script>
    function test()
    if(document.f.htemp.value=="true")
    alert("jus");
    else
    var s=document.f.htemp.value;
    alert(s);
    document.f1.action="success.jsp";
    document.f.submit();
    </script>You cannot run JSP code based on your javascript code.
    Java. Javascript. Not the same thing.
    Hope this helps,
    evnafets

  • Error in a array populated using jsp in client-side in java-script

    hii ,
    I have this problem.
    I have populated an array with records in jsp.The array is being populated correctly ..i hav check it .
    Now I need to get back this array in client side in a java-script function.
    I need this bcoz i need to check whether the value entered in a particular field in the form is there in the table before the form is submitted...hence the need of array.
    Surprisingly in my java-script function i can get back the length of array,but as soon as i am writing something like arr[0] where arr is the name of array populated in server side using jsp,i am get scripting error.
    i.e a code like
    funtion partynamecheck()
    var n=<%arr[0]%>
    alert (n) ;
    is giving scripting error.i.e showing error in page at the bottom left -side of browser.
    but code like
    funtion partynamecheck()
    var n=<%arr.length%>
    alert (n) ;
    } is working fine.
    Please help ..all wrk stuck.
    Arnab

    Hi,
    i cann't help you with javascript, but the jsp-expression must have this syntax
    var n=<%=arr[0]%>
    Hope this help!
    Roland

  • Using java jni

    Hello,
    I'm trying to figure out a way to start small Java-Programs from within
    Labview 6.0.1. Does anybody know how to do this? Every time I use the
    call dll-function to invoke the java-jni api Labview crashes. Invoking
    Java via the active-x plugin doesn't work either.
    Any suggestions are welcome. Thanks.
    Norman Südekum

    Norman,
    Try updating to LabVIEW 6.0.2 to get all of the ActiveX fixes and try the ActiveX method again. (You cannot do this if you only have the Evaluation version.) You can also call java from the System Exec.vi if you do not need data directly back (you can transfer it many other ways: files, TCP, pipes, etc).
    Also, see the following:
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RNAME=ViewQuestion&HOID=506500000008000000102D0000&ECategory=LabVIEW.LabVIEW+General
    http://digital.ni.com/public.nsf/websearch/BEE812007BA2A9B486256BC80068A49A?OpenDocument
    Randy Hoskin
    Applications Engineer
    National Instruments
    http://www.ni.com/ask

  • Need help with jsp that uses a java program

    Hi, sorry for my english but i am italian.
    I've got a problem: i use java builder and i have a java program(this program has got a main and includes libraries) about graphich on tree, this program visualizes these trees and makes operations on these.
    Now i must use JSP so that a client can see this program (this program is on the server) and can interact with it.
    I can't use applet.I must use only jsp.
    Who can tell me how can i start???
    Thanks.

    If you are not allowed to use an applet, then you are limited by what can be achieved with HTML in a browser.
    You would have to figure out how to render it with HTML, then program your jsp to write out this html programatically.

  • Signature Capture for pocket pc using JSP or JAVA

    hello,
    i need to find a way using jsp or java enviornment in which i can capture the signature which the user has signed on my pocket pc .....??
    please let me know what is the ideal way of doing so and what is the best way to transfer it securely to the server ??
    i am using a pocket pc 2000 on hp jornada 568... so the solution should be supported by pocket pc internet explorer
    thanks in advance & regards, :-))
    Prithipal

    You mean like a hand written signiture right?
    That's awesome, that's a really cool idea. And it's not very hard to implement at all. A java applet will be your best bet. Use version 1.1.8 or something for compatibility. All you have to do make a drawing surface for the user to sign, then send it to the server in one of a varity of ways. I would use a single bit bit map, pixels are on or off.
    For the security end you could have your server run SSL. I don't know if the pocket PC supports that though. If it doesn't, the RSA algorithm is open now, the patent expired, and there are several nice java packages available that implement it. So you can just have the applet read a public key from your server, encrypt the data stream with it as it sends it backs. That will be impossible to crack. ( use at least 64 bit keys. )

  • How to call java method using jsp

    how to call java method using jsp.....
    anyone can help me.....i having problem here...coz i very new in java and jsp.....
    thanks.....

    keep an eye on this person's thread...they have code there and everything.
    http://forum.java.sun.com/thread.jspa?threadID=777263&tstart=0

  • Using JSP in Java

    Hi Guys,
    I would like to use JSP as a scripting language to generate output depending on objects that I compute in Java. I am trying to resolve the following scenario:
    1> Generate a JSP page from within a Java Application
    2> Execute the JSP page, capture its output (say in a string) and show it to the user
    I would like to these two steps without having to fidle with web-apps, services, apache and so forth...
    Is it possible to get the above steps to work from within a Java application (using for example tomcat's jar files)? Does anyone know of a sample application?
    Thanks a lot,
    Dirk

    hi,
    1> Generate a JSP page from within a Java Application
    2> Execute the JSP page, capture its output (say in a string) and show it to the user
    you write a client to open the JSP URL and read it's contents then have the client print the returned result and copy it to some destination. You could use a java.net.URLConnection to do this.
    Here is some simple code to read from a url
    private String loadPage() throws Exception
    StringWriter out;
    URL url;
    URLConnection conn;
    BufferedReader reader;
    String inputString;
    out = new StringWriter();
    if ( _logLoads ) System.out.println("Running loadPage, for URL : " + _url );
    conn = _url.openConnection();
    conn.connect();
    if (DEBUG) System.out.println(" connected to server...");
    _contentType = conn.getContentType();
    if (DEBUG) System.out.println(" got Content Type : " + conn.getContentType() );
    reader = new BufferedReader( new InputStreamReader( conn.getInputStream() ) );
    if (DEBUG) System.out.println(" Ready to read data..." );
    while (true) {
    inputString = reader.readLine();
    int index = inputString.toUpperCase().indexOf("<HTML>");
    if ( index >= 0 ) {
    if (DEBUG) System.out.println(" found <HTML> tag in line : '" + inputString + "'");
    out.write( inputString.substring( index, inputString.length() ).trim() + "\n" );
    break;
    inputString = reader.readLine().trim();
    while ( inputString != null ) {
    if ( inputString.length() > 0 )
    out.write( inputString + "\n" );
    inputString = reader.readLine();
    if (DEBUG) System.out.println(" finished.");
    return out.toString();
    }messages copy and paste from our member lancea & caseylou
    regards
    vijay.dr

Maybe you are looking for