tags:

views:

213

answers:

5

i am very new to jsp... i am currently doing a project where i have to interface a card reader with my html page.

i got the card-reader code in a cpp and .h file. is there any way i can use these file with my jsp.. or do i have to recode it in java and include a .js file.

specifically, i have a text input for ID on my page. i need it to be populated with the input from card. i got the code to interact with card and extract that number in cpp program. so can i like call that function from my html page?

+3  A: 

There are several way to do this:

  1. You could do a system call from your jsp if your C++-code can run standalone.
  2. You could use a Java-C++-bridge.
  3. You could use the Java Native Interface.
Benedikt Eger
thanks man. looking into it.
+2  A: 

You will have to look into the Java Native Interface if you want to reference C++ code from java.

For more information see the following:

jjnguy
thanks. i am trying the java-cpp bridge first, sounds quick.
Also -- look at JNA (https://jna.dev.java.net/) - it runs a little slower, but if it's only a few calls per user interaction it won't be noticeable.
Scott Stanchfield
+4  A: 

Why on earth you need to interface your card-reader to your JSP page. It doesn't make any sense to me, I am sorry. First understand that JSP is a Java web technology for presentation, which runs on server and spit HTML to the browser. Hence, what you get on the client is HTML.

Now, could you please elaborate what you are trying to achieve?

Adeel Ansari
we are developing a management software for a hospital, they want the front-end jsp.
Of course, there is no problem in following their requirement. But the main point is to understand the technology you are going to use, in this case JSP. And JSP is not a front-end, as you perceived it. It runs on server and spit HTML to the browser. Calling it a server technology to render front-end makes sense.
Adeel Ansari
Look. You need more help than what you can possibly get from this site. Take some classes and find some good consultants that can help You.
KarlP
Think of JSPs the same way you'd think of a GUI, web service, or command-line. They're all ways to manage interaction with a user (human or otherwise). Write your business logic as though you would be running it from any of the above, making sure that the front-end (JSP, GUI etc) only contains presentation logic.
Scott Stanchfield
@Scott - No, not really, think of JSP as a template language.
Adeel Ansari
+1  A: 

A jsp renders HTML, in the part you will see in your browser you are no longer in your jsp, you are not even in your code anymore.

If you want to read a card from an HTML page you will need to ignore the fact you have jsp technology and realise its HTML technology you are using.

SO you will need an applet, some flash, some activeX or other browser technonlogy first before even trying to interface with the cpp

Peter
hey thanks..okay i have a text input for ID on my page. i need it to be populated with the input from card. i got the code to interact with card and extract that number in cpp program. so can i like call that function from my html page?
A: 

if you need to read from card JSP cannot help you. If you read card number otherwise and send it to JSP with POST, then you do not need any reading. What you might need is signed applet on user's side which will try to read card from card reader. Then I will advise you to use javax.card - java 1.6 has a support for reading smart cards ... http://java.sun.com/javacard/

ante.sabo