2

My Java app download HTML pages from Internet and handle it. Sometimes downloaded HTML pages contain JavaScript code that should be invoked after page loading (JavaScript in <script type="text/javascript"> tags).
It is a possible emulate browser and call JavaScript on serverside?
Here general scenarion desired HTML handling in my app:

  1. Download HTML page
  2. Call all JavaScript in tags
  3. Get HTML after handling with JavaScript

It is a possible to implement above scenarion using Java?
Thank you.

Tomas Narros
  • 13,205
  • 2
  • 37
  • 55
ird
  • 137
  • 1
  • 5

4 Answers4

5

You'll probably want to take a look at Rhino and other JavaScript engines that run in Java. Take a look at the answers to this question that's similar.

Community
  • 1
  • 1
WhiteFang34
  • 66,579
  • 17
  • 101
  • 108
0

Javascript is client side code, you can call a method when the page has loaded either using JQuery or alternativly if you dont want to use JQuery you can implement this

Community
  • 1
  • 1
Euclid
  • 882
  • 10
  • 24
0

Your last question

It is a possible to implement above scenarion using Java?

puzzles me: do you want to use java or javascript? In the latter case javascript engines (as suggested by WhiteFang34) is probably what you're looking for. However, if you want to write complex javascript fron-end application using java and having those application interacting with a java-based back-end, then you may want to have a look at the Google Web Toolkit (GWT).

MarcoS
  • 12,788
  • 5
  • 36
  • 61
0

you want to call javascript at server side. for that you can use jsp in jsp write down out.println("java script"); over here you can use java script

Milan
  • 1