aspose file tools*
The moose likes Applets and the fly likes This applet can it be done in Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "This applet can it be done in Java?" Watch "This applet can it be done in Java?" New topic
Author

This applet can it be done in Java?

kate robin
Greenhorn

Joined: Jul 09, 2012
Posts: 9
Hi everybody,

I am developing an applet which has to use many other websites.In fact i am collecting group of online calculation tools in one.
user has to give me the input data after having choosen the appropriate tool,my applet has to return him the result of calculation without opening the website page of the tool.
almost of this tools pages there is area text where to put data and submit button to get result.

Do you think this applet can be done and what i have to use....i came across httpclient but am not sure other than logging stuff can be done throw it.


Thank you very much
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

It *can* be done, but you will run into the Applet Security model.

Basically, the Applet will only be allowed (by default) to communicate back to the server that hosts it.

Your best bet is to use HttpClient as part of a web application that aggregates the information you need,
then sends that back to the connected client. You could mix and match Applets and JEE but that seems
overkill.

WP
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

To answer your post title: Yes, it has to be done in Java because that's the only language you can write applets in.

But more seriously: Yes, it would be possible to write an applet which goes out to other websites and scrapes data from them. That isn't necessarily an easy task, as it involves a variety of things including HTML parsing, session maintenance, and even due diligence to make sure you have permission from the owners of the other sites.

So far you've identified HttpClient as a possible tool for helping you in this project. You might also look into HtmlUnit, which automates a lot of the tedious stuff involved in connecting to a web site and extracting data from it.

And finally, don't forget that you're going to have to sign your applet, since the basic applet sandbox doesn't permit accessing any servers except the one the applet came from.
kate robin
Greenhorn

Joined: Jul 09, 2012
Posts: 9
Thank you William, thank you Paul for your replies.

In fact am new in web java and this is my first assignment which i have to submit soon.am lil lost...please can you guide me throw clear steps or key words which i can go throw to solve this matter.
thank you...
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Sounds complicated for a first assignment.

Is this work or school related.

As Paul said, an Applet that talks to other sides will be quite complex and the security aspects need to be addressed.

Have you drawn it out on paper or use simple uml or flowcharts as to how it would work (in theory)?

WP
kate robin
Greenhorn

Joined: Jul 09, 2012
Posts: 9
I drew it on paper...it will be this way...

1-User choose calculation tool from a list.
2-user enter data (text).
3-applet connect to link of tool.
4-applet somehow enter user data in textarea of the page of tool website.
5-applet ask website to perform calculation(pressing submit or ok on website page)
6-applet receive the result of calculation from tool website.
7-applet display result in a frame or another applet.

applet apparence is not a problem for me, the complication is how to perform those tasks from different websites(from which i can get permission).

sorry for making it long...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

I haven't used HtmlUnit myself but other people whose opinions I respect have recommended it for this sort of task.

What I would suggest is this: Don't write an applet yet, write a plain old Java application. It's easy to convert to an applet later, but for now keep the applet complications out of the picture. Pick one of your target web sites and have your application try to connect to that. In other words, start simple and don't try to do everything all at once.
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Paul is right.

What you need to do (I think) is simulate a HTTP POST with the correct parameters (after obtaining data from user).
What may be missing here are hidden parameters and potentially any persisted session data once the user has
connected. You may have to maintain all of this within the Applet itself.

WP
kate robin
Greenhorn

Joined: Jul 09, 2012
Posts: 9
Yes Paul i had checked now after you told me about HtmlUnit and came across form submitting possibilty.I will do as you say start simple.but i need to know how to orgonize the connection with the website.
thank you
kate robin
Greenhorn

Joined: Jul 09, 2012
Posts: 9
Hi everybody,
well now i got to run tests by Junit on one sample website, its working well but have a problem:

I want my applet after pressing submit button to launch a Junit test (class which extends TestCase),but how?

i tried putting all testcase class inside the actionperformed method but dosnt work....TestCase class dosnt need a main function to run, just when its alone automatically running and tests going well but how to integrate it inside an applet work?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: This applet can it be done in Java?