How to use DLL in JSP?

          Hello, all,
          I wrote a program to check the user authentication by call Windows's cryptography
          functions. I have generated a DLL file,
          and have put it in the C:\bea\jdk131_03\jre\bin. But my jsp
          page seems ignoring the java code to call the function in the
          DLL. I am not sure what should be imported at the head of the
          jsp file. Would somebody kindly help me out? Thanks a lot!!!
          My jsp code is here:
          <%@ page import="java.sql.Connection"%>
          <html>
          <head>
          <title>
          Jsp1
          </title>
          </head>
          <body>
          <h1>
          JBuilder Generated JSP
          </h1>
          <%
          try{
          if(Ntauth.authenticate("gecorg", "almond", "1025"))
          out.println("Valid user credenticals");
          else
          out.println("Invalid user credenticals");
          }catch(Exception e)
          out.println(e);
          %>
          </body>
          </html>
          

          One of my friend helped me to generate a new dll,
          just changed the package name. Then it works. I don't
          know why. But anyway, it works. Thanks everybody for
          your attention.
          "Sylvie" <[email protected]> wrote:
          >
          >Sorry, I found the function names are not match in my previou
          >post. The name is too long. I missed to type "authenticateNTUser" as
          >"authenticateUser"
          >in the SimpleNTAuthentication.java. I have fixed it. I repost them in
          >the following.
          >So the function name in the .h also corrected. But I still get the same
          >error.
          >
          >Do you know what's wrong?
          >
          >
          >"Sylvie" <[email protected]> wrote:
          >>
          >>Hi, Ann,
          >>
          >>Thanks for replying! But I have checked the function names.
          >>They looks the same. I post the code here, would please have
          >>a look.
          >>
          >>Thanks a lot,
          >>Sylvie
          >>---------------------------------------------------------
          >>SimpleNTAuthentication.java
          >>
          >>package Infolenz.Authentication;
          >>
          >>public class SimpleNTAuthentication {
          >>
          >> static {
          >> System.loadLibrary("ntauth");
          >> }
          >>
          >>
          >> private static native boolean authenticateNTUser(
          >> String domainName, // string that specifies the domain
          >> String userId, // string that specifies the user name
          >> String password // string that specifies the password
          >> );
          >> public static boolean authenticate(String domainName, String userId,
          >>String
          >>password)
          >> {
          >>
          >> if (domainName == null || userId == null || password == null)
          >> return false;
          >> else
          >> return authenticateNTUser(domainName, userId, password);
          >>
          >> }
          >>
          >>
          >>}
          >>---------------------------------------------------------
          >>javah generated Infolenz_Authentication_SimpleNTAuthentication.h
          >
          >/* DO NOT EDIT THIS FILE - it is machine generated */
          >#include <jni.h>
          >/* Header for class Infolenz_Authentication_SimpleNTAuthentication */
          >
          >#ifndef IncludedInfolenz_Authentication_SimpleNTAuthentication
          >#define IncludedInfolenz_Authentication_SimpleNTAuthentication
          >#ifdef __cplusplus
          >extern "C" {
          >#endif
          >/*
          > * Class: Infolenz_Authentication_SimpleNTAuthentication
          > * Method: authenticateNTUser
          > * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
          > */
          >JNIEXPORT jboolean JNICALL Java_Infolenz_Authentication_SimpleNTAuthentication_authenticateNTUser
          > (JNIEnv *, jclass, jstring, jstring, jstring);
          >
          >#ifdef __cplusplus
          >}
          >#endif
          >#endif
          >
          >>----------------------------------------------------------------
          >>ntauth.cpp
          >>
          >>#include "Infolenz_Authentication_SimpleNTAuthentication.h" // native
          >>library
          >>included
          >>#include "stdio.h" // standard input and output
          >>#include "afxwin.h" // MFC core and standard components
          >>#include "jni.h"
          >>
          >>JNIEXPORT jboolean JNICALL
          >> Java_Infolenz_Authentication_SimpleNTAuthentication_authenticateNTUser
          >> (JNIEnv *env,
          >> jclass javaClass,
          >> jstring jDomainName,
          >> jstring jUserId,
          >> jstring jPassword )
          >>{
          >> jboolean authenticated;
          >> HANDLE hToken;
          >>
          >>
          >> // get the provided domain name, user id and password
          >> const char *cDomainName = env->GetStringUTFChars(jDomainName, 0);
          >> const char *cUserId = env->GetStringUTFChars(jUserId, 0);
          >> const char *cPassword = env->GetStringUTFChars(jPassword, 0);
          >>
          >>
          >> // Copy the char array to temporary variables to be
          >> // passed to LogonUser. This copy is done to guarantee the
          >> // const nature of the jstring char array.
          >> // Inappropriate access to this data can crash the VM!
          >> char *domainName = new char[env->GetStringUTFLength(jDomainName)
          >+
          >>1];
          >> char *userId = new char[env->GetStringUTFLength(jUserId) + 1];
          >> char *password = new char[env->GetStringUTFLength(jPassword) + 1];
          >>
          >> strcpy(domainName, cDomainName);
          >> strcpy(userId, cUserId);
          >> strcpy(password, cPassword);
          >>
          >> // release the chars back to the VM
          >> env->ReleaseStringUTFChars(jDomainName, cDomainName);
          >> env->ReleaseStringUTFChars(jUserId, cUserId);
          >> env->ReleaseStringUTFChars(jPassword, cPassword);
          >>
          >> // try to authenticate
          >> if (LogonUser( userId,
          >> domainName,
          >> password,
          >> LOGON32_LOGON_NETWORK,
          >> LOGON32_PROVIDER_DEFAULT,
          >> &hToken))
          >>
          >> authenticated = JNI_TRUE;
          >> else
          >> authenticated = JNI_FALSE;
          >>
          >> // delete the memory that was allocated
          >> delete domainName;
          >> delete userId;
          >> delete password;
          >>
          >> // close the handle created by LogonUser
          >> CloseHandle(hToken);
          >>
          >> return authenticated;
          >>}
          >>
          >>-------------------------------------------------------------
          >>
          >>Ann Cao <[email protected]> wrote:
          >>>Are you using JNI? There are two problems that could cause Unsatisfied
          >>>link errors. One is the DLL not found, and the other is that the DLL
          >>>is
          >>>found but is unreadable or the specific function cannot be found in
          >>it.
          >>>Since you have set your path correctly, I guess the reason you got
          >the
          >>>error is the second cause.
          >>>
          >>>Sylvie wrote:
          >>>
          >>>> I wrote a test java program to call the authenticate function.
          >>>> but get a Unsatisfied Link Error. It seems that my program
          >>>> has problem to load the DLL. But I have set the path to include
          >>>> the directory containing the DLL. Dose somebody know what is going
          >>>on?
          >>>>
          >>>> Thanks,
          >>>> Sylvie
          >>>>
          >>>> "Sylvie" <[email protected]> wrote:
          >>>> >
          >>>> >Hello, all,
          >>>> >
          >>>> >I wrote a program to check the user authentication by call Windows's
          >>>> >cryptography
          >>>> >functions. I have generated a DLL file,
          >>>> >and have put it in the C:\bea\jdk131_03\jre\bin. But my jsp
          >>>> >page seems ignoring the java code to call the function in the
          >>>> >DLL. I am not sure what should be imported at the head of the
          >>>> >jsp file. Would somebody kindly help me out? Thanks a lot!!!
          >>>> >My jsp code is here:
          >>>> >
          >>>> ><%@ page import="java.sql.Connection"%>
          >>>> >
          >>>> ><html>
          >>>> ><head>
          >>>> ><title>
          >>>> >Jsp1
          >>>> ></title>
          >>>> ></head>
          >>>> >
          >>>> ><body>
          >>>> ><h1>
          >>>> >JBuilder Generated JSP
          >>>> ></h1>
          >>>> ><%
          >>>> > try{
          >>>> > if(Ntauth.authenticate("gecorg", "almond", "1025"))
          >>>> > out.println("Valid user credenticals");
          >>>> > else
          >>>> > out.println("Invalid user credenticals");
          >>>> > }catch(Exception e)
          >>>> > {
          >>>> > out.println(e);
          >>>> > }
          >>>> > %>
          >>>> >
          >>>> >
          >>>> ></body>
          >>>> ></html>
          >>>> >
          >>>
          >>>--
          >>>Regards,
          >>>Ann
          >>>Developer Relations Engineer
          >>>BEA Support
          >>>
          >>>
          >>
          >
          

Similar Messages

  • How to use dll in Labview ?

    I compile this code to dll file with VC++2010 filename is test_dll.dll .
    #include "stdafx.h"
    #include <iostream>
    #include <Windows.h>
    using namespace std;
    int main(int a){
        cout << "Test dll...............\n";
        return a;
    After that, I put Call Library Function node in editor and double click Call Library Function node. I browse test_dll.dll into Library name or path and set function prototype to int32_t main(int32_t a); but it show error Call Library Function Node 'test_dll.dll:main':function not found in libraly. How to use dll in Labview ?  And I have more question is what is differrent from Tools -> Import -> Shared Library(.dll) and use Call Library Function node.
    Solved!
    Go to Solution.

    The issue you are having is that LabVIEW is not capable of using C++ DLLs directly. It only handles C DLLs. This does not mean that if you you cannot use the DLL if it's compiled with the C++ compiler as opposed to the C compiler. Rather, it means that you must take extra steps in order to use it from LabVIEW. The primary issue is that of name mangling or adornment. This is discussed here: http://zone.ni.com/devzone/cda/tut/p/id/4877. Basically you need to prepend extern "C" in front of your prototypes in your header files. I would also suggest reviewing this article: https://decibel.ni.com/content/docs/DOC-14564.

  • How to use .dll compiled in Delphi in Java?

    Can anyone provide me information how to use .dll compiled in Delphi in Java? The .dll Delphi program may be non-OOP program.

    Hi
    If You want to write anything in PASCAL then simply write JNI code in C++ and call functions from this DELPHI DLL, but remember about changing the order of parameters etc when You call it. I had exactly the same problem, but it is possible, and we succeed.
    You will need exact description of input parameters required by PASCAL functions and of output parameters. Then construct in C++ objects wchich looks in memory exacly the same as they will look if You will be using PASCAL. Then PASCAL function will interprete this area in memory as known structure and will run.
    Maciek

  • Help me!! How to use JavaScript with JSP ??

    I am using JDeveloper and I created a screen in JSP which uses a bean for database connectivity and retriving info onto the page.
    The page has a ListBox where list items are populated from the database.My requirement is
    whenever the list is changed the page shuold be refreshed with the selected item info.
    I tried to use 'JavaScript' for triggering the event with 'onChange' event of the ListBox.But the event is not getting invoked. I think JavaScript is not working with JSP.
    Please help me with how to Use javaScript with JSP or any other alternative where I can meet my requirement.
    I have one more question...I have gone through the JSP samples in OTN and I am trying do download the sample 'Travel servlet' which show list of countries...etc
    I have also gone through the 'readme' but I don't know how to extract .jar file.
    I would be great if you could help me in this.
    Thanks!!
    Geeta
    null

    We have a similar need. We have used Cold Fusion to display data from Our Oracle Database. We have a simple SElect Box in HTML populated with the oracle data. When someone selects say the State of Pennsylvania. then we have an On change event that runs a Javascript to go get all the cities in Pennsylvania.
    Proble we are having is that inorder for the Javascript to work , we currently have to send all the valid data.
    Do you know of any way to dynamically query the the Oracle database in Javascript

  • How to use EJB in JSP...urgent!!!

    hello,
    i am novice programmer in EJB.
    i am using weblogic 6.1 ...
    my problem is how to use EJB in jsp page.
    my code is as follow..but its not displaying any result.
    <%@ page import="javax.naming.InitialContext,
    javax.naming.Context,
    java.util.Properties,
    firstEJB.First,
    firstEJB.FirstHome"%>
    <%
         long t1 = System.currentTimeMillis();
         System.out.println(t1);
         Properties props = new Properties();
         p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.TengahInitialContextFactory");
         props.put(Context.PROVIDER_URL, "localhost:7001");
         Context ctx = new InitialContext(props);
         FirstHome home = (FirstHome)ctx.lookup("FirstEJB");
         First bean = home.create();
         String time = bean.getTime();
         bean.remove();
         ctx.close();
         long t2 = System.currentTimeMillis();
    %>
    <html>
         <head>
              <style>p { font-family:Verdana;font-size:12px; }</style>
         </head>
         <body>
              <p>Message received from bean = "<%= time %>".<br>Time taken :
              <%= (t2 - t1) %> ms.</p>
         </body>
    </html>
    please tell me the solution.

    Hi, I don't know if it may be the cuase of your problems, but you should narrow the Object obtained doing the lookup, like this:
    FirstHome home = (FirstHome) PortableRemoteObject.narrow(ctx.lookup("FirstEJB"), FirstHome.class);

  • How to use taglibs in JSP for Database access

    Hi
    Could any one please tell me how to use taglibs in JSP for Database access
    with regrds
    Jojo

    This is a sample how to connect to a MySQL database with JSTL 1.0:
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>JSTL MySQL</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <c:catch var="e">
    <sql:setDataSource var="datasource" url="jdbc:mysql://Your_Server_Name_Here/You_Schema_Here"
                           user="Your_Username_Here" password="Your_Password_Here"
                           driver="com.mysql.jdbc.Driver"/>
    <c:out value="datasource= ${datasource},  Class = ${driver.class}"/>
    <br />
    <br />
    <sql:query var="deejays" dataSource="${datasource}">SELECT * FROM Your_Table_Name_Here</sql:query>
    <table>
    <%-- Get the column names for the header of the table --%>
    <c:forEach var="columnName" items="${deejays.columnNames}"><th><c:out value="${columnName}"/></th></c:forEach>
    <tbody>
    <%-- Get the value of each column while iterating over rows --%>
    <c:forEach var="row" items="${deejays.rows}">
      <tr><c:forEach var="column" items="${row}">
            <td><c:out value="${column.value}"/></td>
          </c:forEach>
      </tr>
    </c:forEach>
    </tbody>
    </table>
    </c:catch>
    <br />
    <br />
    <c:if test="${e!=null}"><span class="error">Error</span>�
      <c:out value="${e}" />
    </c:if>
    </body>
    </html>And this thread might help you:
    http://forum.java.sun.com/thread.jspa?threadID=639471&tstart=44

  • How to use JOptionPane in jsp, instead of javascript message alert box?

    HI,
    How to use JOptionPane in jsp,
    instead of javascript "message alert box"?
    I hate javascript,
    I'd like to only use java in jsp. don't use javascript.
    javascript is client side,
    jsp is server side. i know that.
    how to... instead of javascript box?
    how to use ... message box in webpage?
    don't use applet,,,, don't use javascript,,,
    hm...zzzZzz
    I hate javascript..T.T
    <SCRIPT language=JavaScript>
    alert("hate javascript");
    </SCRIPT>
    ===>>>>
    In this way,,
    JOptionPane.showOptionDialog(null,"I love java")
    I'd like to only use jsp and java and html...in webpage.
    don't use javascript....
    Why? don't sun provide message box in jsp, instead of javascrip box?
    Why?
    Edited by: seong-ki on Nov 4, 2007 8:38 PM

    Drugs are bad, m'kay?

  • How to use cookies in jsp

    Hi all,
    I'm new to jsp, please let me know how to use cookies with jsp.
    I have three web applications, in run time I have to switch from one application to another application based on single login page. I have taught cookies are one of the solution. But while I'm googling I unable to get such a good material.
    please give some examples,
    Thanks in advance.
    achchayya

    Read a cookie in jsp
    HttpSession session = request.getSession();
    Cookie cookie_session = getCookie(request, "COOKIENAME");
              if (cookie_session == null) {
                   sesID = session.getId();
              } else {
                   sesID = cookie_session.getValue();
              }or
    get all cookie in the browser
    This gets all the cookies and according to the cookie name given u can get the cookie value
    Cookie[] cookies = request.getCookies();
              if (cookies != null) {
                   for (int i = 0; i < cookies.length; i++) {
                        if (cookies.getName().equals(cookieName))
                             return cookies[i];
                   }but i am not sure if this works for ur requirement try and see                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to use threads in JSP???

    hello
    i want to use threads with JSP.
    i want to write a jsp page which will
    start 2 different threads. the 1st thread should just display a message and the second page should redirect this page to another jsp page.
    till the redirection is goin on, the message should be displayed in the browser from the 1st thread.
    i dont know actually how to use threads in JSP by implementing the Runnable insterface, if not m then how do i do it ??
    thanx
    Kamal Jai

    Why do you want to use threads to do this ??
    If you write a message and do a redirection, the message will be displayed until the other page will be loaded into the browser...
    I already launched a thread from a JSP but it was for a four hour process where the user can close his browser windows.

  • How to use datagrid in jsp ?

    Hi All ,
    Can any body let me know , how to use datagrid in jsp pages .I have downloaded the taglibs-datagrid.jar file and taglibs-datagrid.tld. I have saved the .jar File in the WEB-INF/lib and .tld to the WEB-INF directories.
    I wrote a program that is getting a collection from the request and i just want to display the objects in the datagrid.Please help me out of this problem.It's better to explain with example. Waiting for a response.
    Regards,
    Rakesh

    Why do you want to use threads to do this ??
    If you write a message and do a redirection, the message will be displayed until the other page will be loaded into the browser...
    I already launched a thread from a JSP but it was for a four hour process where the user can close his browser windows.

  • How to use DLL written in VB in JSP

    I have a .dll written in Visual Basic. I want to use that dll in JSP. can anyone tell me is it possible? if yes than how.
    please rely with a complete example.
    Thanks in advance
    Lalit

    I thought JNI required that it be a C++ DLL.
    Maybe you could wrap that DLL as a COM object and used a COM bridge to talk to it.
    "please rely with a complete example." - I don't have one, but if I did I'd ask you to please reply with a lot of USD. This isn't an on-demand free consultancy, you know.

  • How to use chart in jsp by using  MS Acess Db

    hii
    My application is to generate the report using the chart with the help of MS Acess
    i heard abt the JFreeChart . I downloaded it but i dont know how to link and use it in my application
    plz help me.....
    Thank u in advance

    I downloaded it but i dont know how to link and use it in my application I'm sure they provide some examples how to use it.
    Look at them and try to understand how a JFreeChart is used.
    When you have a concrete question about JSPs an JSTL you may come back and ask again.
    If you have questions about JFreeChart ask them in the JFreeChart Forum.
    andi

  • How to use dll function in JDeveloper?

    I want to use function in dll to develope my application,but
    I can't find how to do that in the JDeveloper document.
    null

    You have to use the Java Native Interface to use dlls. The JNI
    tutorial at http://java.sun.com/docs/books/tutorial/native1.1/
    walks you through the basics and provides a sample too.
    Hope this helps.
    Regards,
    yinjun (guest) wrote:
    : I want to use function in dll to develope my
    application,but
    : I can't find how to do that in the JDeveloper document.Who can
    : give me an answer? Thanks a lot in advance.
    null

  • How to Use DLL Function in Java Applet

    Hi all,
    I have been assigned a task to develop java applet. The problem is, I need to use DLL functions in my applet to read records. Could you pls anyone guide me how to interface DLL and applet to read records with sample code?
    I'm using JDK 1.5.0_06 and Windows XP OS. thanx..
    best rgds,
    jpdbay

    You will need to use Java Native Interface JNI. Ther are many posts on the subject, please search, and this is the documentation:
    http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/jniTOC.html

  • How to use XMHTTP in jsp

    Hello,
    can any body tell me how to use the XMHTTP in jsp programming are servlet..what i know is XMLHTTP used in with java script functions..for connecting to servers without refrshing the page.can we use directly in jsp page.if so which APIs we have to use..provide me some help..
    regards,

    Thanks Steve for ur reply..
    XMLHTTP is a microsoft related thing..How so? This code works with Firefox & IE6 on Tomcat 5:
    <%
    String aStr = request.getParameter("a");
    String bStr = request.getParameter("b");
    String cStr = "";
    int a,b,c;
    if (aStr != null && bStr != null) {
         a = Integer.parseInt(aStr);
         b = Integer.parseInt(bStr);
         c = a + b;
         cStr = ""+c;
    } else {
         aStr = "";
         bStr = "";
    String acc = request.getHeader("Accept");
    if (acc!=null && acc.indexOf("message/x-jl-formresult")!=-1) {
       try { out.print(cStr.trim()); } catch (Exception e) { e.printStackTrace(); }
    } else {
    %>
    <html>
         <head>
             <title>Add</title>
         </head>
         <body>
              <script>
                   var xmlhttp=false;
                    try {
                     xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                    } catch (e) {
                     try {
                      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                     } catch (E) {
                      xmlhttp = false;
                   if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                     xmlhttp = new XMLHttpRequest();
                   function calc() {
                    try {
                     frm=document.forms[0]
                     url="addbyxmlhttp.jsp?a="+frm.elements['a'].value+"&b="+frm.elements['b'].value
                     xmlhttp.open("GET",url,true);
                     xmlhttp.onreadystatechange=function() {
                      if (xmlhttp.readyState==4) {
                       document.forms[0].total.value=xmlhttp.responseText;
                    xmlhttp.setRequestHeader('Accept','message/x-jl-formresult');
                    xmlhttp.send(null);
                    } catch(E) { alert (E.message); }
                    return false
              </script>
              <form action="addbyxmlhttp.jsp" method="get" onsubmit="return calc();">
                   <input type="text" name="a" value="<%=aStr%>"/> +
                   <input type="text" name="b" value="<%=bStr%>"/> =
                   <input type="text" name="total" value=""/>
                   <input type=submit value="Calculate">
              </form>
         </body>
    </html>
    <%
    %>That is a direct translation from one of the examples on the page I pointed to earlier.
    do we have any
    apis in java insteead of
    var xmlhttp = new
    ew ActiveXObject("Microsoft.XMLHTTP");
    var xml_dom = new
    new ActiveXObject("MSXML2.DOMDocument");
    var xml_domTemp = new
    new ActiveXObject("MSXML2.DOMDocument");
    these things i want to use java related stuff..is it
    possible..
    regards,Those things are JAVASCRIPT!! Like I said, most of the work is done in javascript, not the server side stuf.. And the page I pointed you to answers that question.

Maybe you are looking for

  • Various problems since Mavericks update

    Since doing the Mavericks update a few days ago, I'm having a few issues with seemingly unrelated programs. 1) Quicksilver Works perfectly except for the triggers (shortcuts) that act on selected text. Eg normally I could select the word 'text' in th

  • How to populate multiple entries to Bapi Table

    Hi all,   How to populate multiple entries to Bapi Table..... Here is the code(in component controller)   Z_Recr_Apply_Point_Input request = new Z_Recr_Apply_Point_Input(WDModelScopeType.TASK_SCOPE);        int  size = wdContext.nodeApplicants().size

  • Staying asleep after opening

    Hi There: My MBP seems to periodically not come out of sleep after I open it. Is this normal? Also, it sometimes will come out of sleep when closed. I hear ichat connect and see the apple light up. Not too sure whats going on here. Thanks

  • Settting boot kernel architecture with Apple Script

    Ok, so on three different sites, I've got a total of about fifty Macs, the majority of which run 10.6.8. I need to install a remote monitoring application on the machines, but the application only runs on the 64 bit kernel. I'd really like to set the

  • How to access my icloud videos

    I need to access videos from my icloud and cant find it.