Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a Java Servlet 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I am attempting to set up an Internet Shop Payment App.
The shopping cart is written and doing the right things but I have hit that wall, where I can't see the wood for the trees.
The required script needs to gather the info from a submitted HTML form, store the details locally and then run a java servlet to create a security feature.
The data and the created security feature are then posted to the bank for the payment process to take place.
Once the payment has been processed the visitor is redirected to another page and the store (us) receive a return post with all the relevant transaction codes to tell us the status of the payment etc.
Sounds impressive but I have a problem.
How do I call the java servlet?
Do I need to set the permissions for the java files?
Do Java files need to be compiled?
How do I redirect the script to the bank's URL?
The rest of it has been proved and works well but I need help with this bit.
I realise that some of my questions are off topic but I would be grateful if someone would assist me with the redirection part.
Thanks

Keith
 
You can't really just 'call' java classes and expect them to act like a servlet. A servlet is basically a specific java class in a web context, similiar to the difference between a 'cgi script' and a 'perl script'.

The only way to handle this cleanly is to use LWP to make your POST or GET request to the servlet, grab the result and display it back to the user. Your script will proxy the transaction for the user in this instance.



 
Thanks for the reply.
I may be wrong when I refer to the object in question as a servlet. When I asked the bank's 'unhelpful line' what is the correct term for the object they asked me which object I was referring to. In the bank's set-up it is referred to as a Servlet and also a Library.
I know that what ever it is it has to be declared, vars. passed to it and it returns a hash but I am still no clearer on how to do it.
Code:
[i]
The only way to handle this cleanly is to use LWP
[/i]

What is LWP?
Code:
[i]
Your script will proxy the transaction for the user in this instance
[/i]
Please explain in non tech jargon.
Thanks



Keith
 
You are trying to do something technical. Thi is not jargon.

Look,the servlet is running as a webapp. You can't just "call" the library, you have to access the webapp. This is the core concept here. The libary must run in a servlet context via a webserver.

This means you must make perl emulate a web-browser. LWP is a perl module that allows you to make web requests to specified URL's and retrieve the result of those.

So in this case you would use LWP to make a web request to the servlet URL, post your data and retrieve the result.

Servlets don't return hashes, you can't declare servlet variables in perl. They are two totally independant systems that you need to graft together using LWP.

Check out LWP on CPAN, maybe that will help clear up some of the concepts for you. This is a pretty common situation so once you understand that interactions you should not have to much trouble.
 
I'll check out LWP and see if I can make sense of it.
The whole point of the process is to pas vars to an external library, within my own server space. The function of the call is to return a hash which is used for further processing within the same script that called it in the first place. If servelts do not return hashes then it may not be a servet.
The obvious place to get answers would be the bank's tech guys but they are advising me to load 'c' librarys to make a Java function operate, this seems rather odd. This is why I turned to Tek-Tips in order to pick the brains of knowledgable people.
I'm sorry if I am appearing to be thick but I am not as fortunate as the people who were born with this knowledge. I am having to learn it from the floor up.

Keith
 
Your taking many distinct concepts and meshing them into one thing that is not really a real thing.

1) You can't call java libs directly from perl
2) You can't pass in memory structures (variables) between Java and Perl (at least not easily)

You need perl to act like a webbrowser and request a page load from a URL that is the URL of the servlet.

 
There are 2 other options within the examples I have been given, COM objects and C librarys. Would it be easier to interface one of these rather than go down the JAVA route?

Keith
 
No, ths java servlet route is pretty easy. Directly calling a C or COM lib will be even harder. You get into library wrapping in XS etc etc.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top