ird
ird

Reputation: 147

It is a possible call JavaScript code inside HTML page on server-side (Java)?

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.

Upvotes: 2

Views: 2622

Answers (4)

Milan
Milan

Reputation: 1

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

Upvotes: 0

MarcoS
MarcoS

Reputation: 13574

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).

Upvotes: 0

Euclid
Euclid

Reputation: 910

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

Upvotes: 0

WhiteFang34
WhiteFang34

Reputation: 72079

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.

Upvotes: 5

Related Questions