Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes Server Side JavaScript Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Server Side JavaScript Question" Watch "Server Side JavaScript Question" New topic
Author

Server Side JavaScript Question

Michael McNally
Ranch Hand

Joined: Aug 22, 2002
Posts: 53
I want my server to execute a JavaScript that randomly chooses properties from a previously defined array list to create a new list of random properties. I am very familiar with client-side JavaScript but I know that this script must be run from server-side if the newly returned list is to remain the same. Otherwise, if it was run from client-side, it would always change randomly and every client would have a different list.
So, I have two questions. 1) Is Server-Side JavaScript only supported by Netscape or is it also supported by Internet Explorer? 2) What code would I have to write to store my new list of values onto the server for everyone to see without it being changed? If I wrote a client-side cookie, the values would be stored yet each client would have a different version.
I am very confused, please help
Michael
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Well if you need to store stuff in a database you are going to need a server side language like JSP or ASP. Cookies are not a good way to store information since a person may not have them enabled, or they might delte them on a daily basis.
To have everything be random with no repeating is going to rely on the database and checking to see if that combo has been met. Most of this should be done on a server side. If you do not need everything to be completely random, then you can just use a random number generator to get the information from the array on client side and pass them to the server side.
Now that I probably lost you or did not answer your question I will stop and get to work.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

Is Server-Side JavaScript only supported by Netscape or is it also supported by Internet Explorer?

The browser used is immaterial. What matters is whether your web server supports server-side JS. And Netscape Server (is that even still around?) is the only one I've ever heard of that does.
I'd follow Eric's suggestion of a more commonly used server-side mechanism. Obviously JSP/Servlets are a natural choice for most readers of these forums.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Michael McNally
Ranch Hand

Joined: Aug 22, 2002
Posts: 53
How frustrating. JSP and ASP programming languages: How different are they in relation to JavaScript? Are they object oriented languages?
Can I use my JavaScript function to return the data and then send that data to my database using JSP? Or do I have to start from scratch using JSP?
Maybe you could navigate me to a tutorial website for JSP or ASP?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

Michael, do a search on the JSP forum. Tutorials and such info have been posted a number of times.
hth,
bear
Jane Somerfield
Ranch Hand

Joined: Jul 20, 2002
Posts: 193
Why do we need server side JavaScript? What Servlet/JSP can not do
but JavaScript?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
What in the world are you asking?
Jane Somerfield
Ranch Hand

Joined: Jul 20, 2002
Posts: 193
It is first time I heard running JavaScript on server side.
My understanding is that JavaScript with HTML runs in web browser,
not in web server.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
It can run on the server, but it is very limited on what it can do just like any server side language. Do not use it on server side, stick to a lanuage that was built for it.
Eric
Jane Somerfield
Ranch Hand

Joined: Jul 20, 2002
Posts: 193
Eric, Thanks for answering my questions. Jane.
 
Consider Paul's rocket mass heater.
 
subject: Server Side JavaScript Question