wood burning stoves
The moose likes Java in General and the fly likes capturing javascript output from module Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "capturing javascript output from module" Watch "capturing javascript output from module" New topic
Author

capturing javascript output from module

Zack Lamm
Greenhorn

Joined: Aug 04, 2007
Posts: 3
I'm working on a project that is meant to speed up the load
time of a website. Basically, what I need to do is translate
a javascript module and save the output to a database.

I've tried using javax.script.*, but the modules use implicit
objects (such as "navigator"), so when I try to evaluate
the modules my app crashes. Is there any way around this?
Possibly using other tools such as Python/Ruby???

Program outline:

1. grab module from file or url
2. interpret module and capture output
3. save output to database

An example of one of the modules I'm working with:
Javascript module

Any comments, suggestions are welcome...I'm up against a brick wall here.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 62138
    
  68

Originally posted by Zack Lamm:
Basically, what I need to do is translate
a javascript module and save the output to a database.


Translate it to what?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Zack Lamm
Greenhorn

Joined: Aug 04, 2007
Posts: 3
I need the output from the Javascript, i.e., all the document.write statements...
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42954
    
  73
A script like that only makes sense in the context of a web page. Are you using a library like jWebUnit to simulate a web page environment?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 62138
    
  68

'm working on a project that is meant to speed up the load
time of a website.


Perhaps you should explain what you mean by this.

If you are trying to "speed up the load time" by running the JavaScript on the server before it gets to the page, well, that's just not going to be possible.
Zack Lamm
Greenhorn

Joined: Aug 04, 2007
Posts: 3
No, I haven't tried jWebUnit, does it support javascript?
I tried using httpunit, but it has limited javascript support.
Simulating a web environment is exactly what I want to do.
Basically, all I need is the javascript module to run through
a browser so I can capture the output, like I said before, I
need everything that's produced from the document.write()
statements. That's what goes into the database: the actual
content that's produced from the javascript module.
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42954
    
  73
I don't fully understand what you're trying to do, but I prefer jWebUnit over HttpUnit. It has much better support for DOM and JavaScript, and also operates on a higher level, which makes for a more pleasant development experience.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: capturing javascript output from module