aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to invoke a java class which is not an applet from the html page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to invoke a java class which is not an applet from the html page?" Watch "How to invoke a java class which is not an applet from the html page?" New topic
Author

How to invoke a java class which is not an applet from the html page?

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
I would like to know is there any way to invoke a java code(which is not an applet)from the html page.....
thanks in advance


Abhishek
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Please take the time to choose the correct forum for your posts. This forum is for questions on advanced Java.

This post has been moved to a more appropriate forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Sure, you can submit a form or cause a link to activate a servlet on the server. Alternatively, you could employ Ajax to make a request to a servlet.

Or, a JavaScript library named DWR uses Ajax and servlets to allow you to make what seem to be RPC-like calls to Java methods.

All that assumes, of course, that you are talking about running Java code that resides on the server. If it is client-side Java that you are asking about, then an applet is necessary.
[ June 24, 2007: Message edited by: Bear Bibeault ]
Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
thanks for the reply......
my job is to interract with the smartcard.......the drivers are installed on the client machine...

i wrote a java application which works fine...but my application has to be integrated with the web application..

My application will be on the client side.......my application has to get the data from the html page and interract with the smart card....

Now tell me how can i pass data from my html page to the java class...
thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
Sounds like you need an applet on that web page. To interact with the smartcard reader it will need to be signed, which is explained in HowCanAnAppletReadFilesOnTheLocalFileSystem.

There are two ways for the applet to interact with the web page it's on: LiveConnect and the Common DOM API. Links about both can be found here.
[ June 25, 2007: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
Mr.Ulf Dittmer thanks for the reply......
I dont want to use the applet is there any other way.........
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
An applet is the only way of the web page is displayed in a browser.

Now, if the web page doesn't need to be displayed in the browser (meaning it only has to interact with smartcard reader, not with the user), then you could use a a library like jwebunit to load the web page into your Java application, access its contents, submit forms etc. Is that feasible in your scenario?
Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
thanks for the quick reply...
what i have to do is.....
i have to fill the html form fields which comes from the server and when i click the submit button all the form fields data should form a big string and some how my html page should invoke a method in a java class passing the string as a parameter....
by means of this data will be entered into the smart card...

and similarly for retrieving .....
hope you understand my requirement..
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
If the smart card is connectd to the user's machine, you are going to have to run an applet to do it.

Eric
Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
hi Eric Pascarello
thanks for the reply......
tell me applet is the only way to interract with the smart card...
i wrote a java class (which is not an applet)which will interract with the smart card...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
Do you see any problems in using the class you wrote as part of an applet?
Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
my java class is not part of an applet.....
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Originally posted by Abhishek Reddy Chepyala:
my java class is not part of an applet.....


And the reason why you can not make it part of one?

Eric
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Abhishek,

I believe you are missing an important detail about what you are trying to do. Web applications on the client side (HTML and Javascript) cannot talk to devices connected to your PC. So for example, this UBB Software that we run for Javaranch cannot communicate with any devices currently connected to your PC. That is why everyone is suggesting an Applet. It runs inside a web browser, but can talk to hardware devices just like a regular thick client desktop application can.

The nice thing about an Applet though is that it's deployed as such to a single server and anyone can access it through their web browser, provided they have the JRE installed. You just need to be aware of security issues with Applets which Ulf has pointed out and linked information for you.

Since this really isn't about HTML or Javascript anymore I'm inclined to move it to a more appropriate forum however I'd be hard pressed to know which without a decision on your part. If you choose to go with an Applet I'll move it to that forum and we can continue to help you in your quest. Otherwise, we'll need to know which route you choose to take to make that decision.

Thanks.


GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to invoke a java class which is not an applet from the html page?