Solved

combine serverside javascript with perl?

Posted on 1998-01-04
9
288 Views
Last Modified: 2012-08-14
here is my problem:
I use to have a perl cgi script that open a socket connection and pass some text to another end of the connection.
Now I have written some server side javascript code to read an Oracle database to perform access control (for authentication).
Life would have been easy if I could use this javascript to pass data through a socket connection but from my very limited knowledge on javascript this doesn't seem possible.
So can I somehow wire my perl code and this javascript code together?
If this is not possible, how about if I change the perl portion to java, and is it possible then to use liveconnect to wire them up? Can someone inform me of the simplest solution?
0
Comment
Question by:enotsin
9 Comments
 
LVL 10

Expert Comment

by:kollegov
ID: 1277325
Netscape's servers support
some databases ODBC, Informix, ORACLE and some others
connectivity directly from LiveWire server-side script.

It also support liveConnect methods, but I think
easier to do all in one as (Java servlet)
Java have JDBC allowing to connect to databases
and java servlets can connect via socket to anywhere.
Sun released JSDK (servlets developers kit and it's free!)
and can be easy plug-ined under most existing of major servers.
I'd recommend to use servlets instead of Netscape's "server applets", at least this ones easy can be moved to any other
(non-netscape) server.
0
 
LVL 1

Expert Comment

by:nanullnet
ID: 1277326
Why not just write the Javascript portion in perl?  Perl can connect to the Oracle DB.
0
 

Author Comment

by:enotsin
ID: 1277327
do you mean using the Win ODBC package in Perl? I have that one with my Perl 5 but haven't use it before. What do I need to get that running? Is it a ODBC/oracle driver? does it come with oracle?
0
 
LVL 1

Expert Comment

by:nanullnet
ID: 1277328
Which port of Perl are you using?  The ActiveState port has great Win32 support.  Dave Roth has an ODBC module for perl, and I think it works on the standard port too, but don't quote me on that.  As long as the Oracle DB has ODBC support, you can use the ODBC module to connect to it.  If you are on UNIX, there is a Native ORACLE driver you can use with Perl, but I'm not aware of one for Win32.  But if you have ODBC support, Perl will work great.  I can give you code samples if you like.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:enotsin
ID: 1277329
I forgot which port of Perl I am using. But it has a directory
perl\lib\site\Win32
which contains David Roth's ODBC.pm (ver 0.03)
another directory
perl\lib\site\DBD
contains another ODBC.pm by Tim Bunce et al
can you give me an example how to write perl code to connect to my oracle workgroup server?
(ps, I don't know this odbc stuff, but say I have the oracle server on my NT4.0 machine and that machine's ODBC applet in its control panel doesn't show anything. Do I need to setup something there first?
0
 
LVL 1

Accepted Solution

by:
nanullnet earned 40 total points
ID: 1277330
Yes, first you need to set up a system DSN.  Do that and follow the directions.  Select the Oracle ODBC driveer when it asks you.

Once that is done, the Perl code will look something like this:

use Win32::ODBC;
$DBCONN = new Win32::ODBC("DSN=xxxx;UID=xxxx;PWD=xxxx;");
$SQLString = "INSERT INTO UserRec (U_item, U_time) VALUES ($item, $t)";
$ERROR = $DBCONN->Sql($SQLString);
die qq(SQL failed "$SQLString": ), $DBCONN->Error(), qq(\n) if $ERROR;
$DBCONN->Close;

That works fine with Dave Roth's module and the Active state port.  Try it on your machine.
0
 

Author Comment

by:enotsin
ID: 1277331
thanks! but what's this DSN thing? How do I setup it and where to get it? does it come with my oracle server?
0
 

Expert Comment

by:zingbust
ID: 1277332
Hi,
  Sorry I can't help you with the DSN thing.  I just had a question about what you said in your original question.  You said you had server-side javascript code to read the database.  I didn't know there was such a thing.  I thought javascript only ran embedded in HTML which would mean it was client-side.  If there's such a thing as server-side javascript, I'd really like to learn about it because that may be the key I'm looking for to solve my problem.
0
 

Author Comment

by:enotsin
ID: 1277333
Server side javascript and server side java are both available. The former was introduced by Netscape to run livewire application that connect to database. The later was introduced by javasoft in the form of servlet.

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now