Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Server-Side JavaScript

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not know where should I put this topis. Sorry for that.

I have a problem. I have to prepare an example of server-side JavaScript. I must show this example during my classes.
Which server can I use?
I searched for that using google, but I noticed that SSJS is very old and I am not able to get environment for that.
What server should I use? Give me some information.
Can you help me, please?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the only server that supported that out of the box was Netscape iPlanet, and that's long gone.

But a web app could use JavaScript scripts to do any number of things (say, for configuration or customization). There's a very capable JavaScript implementation written in Java that you could use for this; it's called Rhino and is available at www.mozilla.org/rhino. (Starting with Java 6, it's also part of Java SE, and can be used through the javax.scripting API).
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, and it can be said that it's server-side implementation of JavaScript?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a server-side use of JavaScript. The implementation (Rhino) is agnostic of any use you may put it to.
 
Rob Spoor
Sheriff
Pie
Posts: 20532
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe Lucas is looking for a server that will execute JavaScript in the same way as Tomcat executes JSP, IIS executes ASP with VBScript and the PHP engine executes PHP pages.

If I recall correctly, ASP can execute JavaScript (or JScript). See http://www.w3schools.com/asp/asp_syntax.asp and http://aspjavascript.com/.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe Lucas is looking for a server that will execute JavaScript in the same way as Tomcat executes JSP, IIS executes ASP with VBScript and the PHP engine executes PHP pages.

If that's the case, then Jakarta BSF 2.4 can be used in conjunction with the BSF taglib to enable JavaScript's use as a scripting language in JSPs. It's not quite as "first-class" as Java in general is in JSPs, but it may fit the bill.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,
I want to execute something like this:


As it stands in:
http://docs.sun.com/source/816-6411-10/sampapp.htm#1012740

What should I do?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh dear, that looks indeed like a manual for the old Netscape server, which Sun took over at some point, and which has been obsolete for years. It's modern-day heir is the http://en.wikipedia.org/wiki/Sun_Java_System_Web_Server, but I've no idea if it still has that JavaScript support. I would guess not, because that's what JSP is used for these days in the Java world.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So no rescue for me
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created something like this:



prime.js


What do you think? Is it a good example of server side JS?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's functional, but a bit dull, since it doesn't provide any benefit that straight Java code couldn't have provided, too. If the script resided in its own file, and if there were a background job that periodically checked whether the file had been updated, and if it was, reloaded the script, you'd have something that would be handy for dynamic server reconfiguration.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that it's dull but I only want to show an example of SSJS during classes
I noticed that there are no default JS objects using Rhino - like document, window...
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I noticed that there are no default JS objects using Rhino - like document, window...

Those are reliant on a browser environment, so it wouldn't make sense for Rhino to implement them.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for help. I'll see what PhD will say about my example of SSJS :P
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic