Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use external server side jar in GWT?

Tags:

java

gwt

jsoup

I want to use jSoup on GWT server side code to be able to scrape web pages. The documentation of GWT does not help in installing external jars. Can anyone tell me how do I install the jSoup jar (downloaded from the official jSoup site) in GWT and use it in the server-side code?

like image 923
SexyBeast Avatar asked Jan 09 '13 07:01

SexyBeast


2 Answers

By using eclipse you can do the following:

  1. Download the jsoup.jar
  2. Copy the file to the lib library of the project WEB-INF/lib
  3. Right click on the lib folder inside eclipse Refresh to see the new library.
  4. Add the library to the class path: Right click on the Project -> Build Path -> Configure Build Path -> Add external jar. Browse and add the jar
  5. Write the import jsoup statement inside any server side class and you can use it as usual.
like image 64
Athanasios Kataras Avatar answered Nov 19 '22 09:11

Athanasios Kataras


If you are using it via simple GPE eclipse project then keep it in the WEB-INF/lib .

If you are using it via a maven GPE eclipse project then add to runtime classpath scope in dependencies.

Client server interaction in either of the above scenarios:

Step 1 - RPC Call to request processing of URL.

Step 2 - RPC Server side code i.e servlets for requesting and scraping a url http://vjdef.com/home/2011/06/scraping-html-using-java-servlets-and-tagsoup/

Step 3 - RPC Server side code sends back required message post processing to client.

Step 4 - onSucess callback of the Step 1 RPC invocation will receive message.

like image 2
appbootup Avatar answered Nov 19 '22 08:11

appbootup