This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Server-Side JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Server-Side JavaScript" Watch "Server-Side JavaScript" New topic
Author

Server-Side JavaScript

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

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?


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39529
    
  27
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).


Ping & DNS - updated with new look and Ping home screen widget
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

OK, and it can be said that it's server-side implementation of JavaScript?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39529
    
  27
It's a server-side use of JavaScript. The implementation (Rhino) is agnostic of any use you may put it to.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19538
    
  16

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39529
    
  27
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

Joined: Apr 20, 2009
Posts: 804
    
    1

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
Marshal

Joined: Mar 22, 2005
Posts: 39529
    
  27
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

Joined: Apr 20, 2009
Posts: 804
    
    1

So no rescue for me
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

I have created something like this:



prime.js


What do you think? Is it a good example of server side JS?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39529
    
  27
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

Joined: Apr 20, 2009
Posts: 804
    
    1

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
Marshal

Joined: Mar 22, 2005
Posts: 39529
    
  27
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

Joined: Apr 20, 2009
Posts: 804
    
    1

Thanks for help. I'll see what PhD will say about my example of SSJS :P
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Server-Side JavaScript
 
Similar Threads
JavaScript Object Based Programming / Object Oriented Programming??
showing one form if the other form is submitted
controlling going back to previous page after logout
AJAX Complexity
How to check if textboxes are null