JSP vs. Javascript

R

Robert M. Gary

I've noticed in several forums that people are making a clear
distinction between Javascript and JSP. I guess I've used the terms
interchangably. I can't seem to find anything in Google to describe
what might be different between the two.

-Robert
 
S

Sheridan

They are completely different technologies. JSP is really more akin to
ASP or PHP than it is to Javascript. JSP uses Java technology to build
pages on the server which are then served to a client, Javascript is a
client-side scripting technology.

For more information on JSP's start here:

http://java.sun.com/products/jsp/faq.html

Sheridan
 
Z

zero

I've noticed in several forums that people are making a clear
distinction between Javascript and JSP. I guess I've used the terms
interchangably. I can't seem to find anything in Google to describe
what might be different between the two.

-Robert

the easiest way to see the difference is one simple sentence: JSP runs on
the server, JavaScript runs on the client.

As a result, JSP is more used to change the *contents* of a webpage, and
JavaScript for the *presentation*. It is quite common to use both on the
same page.

Furthermore, JSP uses Sun's Java technology. Despite the name, JavaScript
has little to do with Java - the syntax just looks a little alike, but then
so does C++
 
O

Oliver Wong

zero said:
the easiest way to see the difference is one simple sentence: JSP runs on
the server, JavaScript runs on the client.

As a result, JSP is more used to change the *contents* of a webpage, and
JavaScript for the *presentation*. It is quite common to use both on the
same page.

Furthermore, JSP uses Sun's Java technology. Despite the name, JavaScript
has little to do with Java - the syntax just looks a little alike, but
then
so does C++

To elaborate on zero's responce, both technologies are typically used in
an web environment, with the client using a web browser to interact with a
web application hosted by a server. The server will run the JSP code, and
will typically emit HTML code. Within that HTML code, there may be some
JavaScript code embedded within it.

The client will never see the JSP code, and has no control over it. All
the client receives is the HTML code (with optionally some JavaScript
embedded in it). The browser may then run the JavaScript code. Or perhaps
the user may have JavaScript disabled on their browser, in which case the
JavaScript code will not run at all.

Because of this, it is unwise to put "critical behaviour" in JavaScript,
as it might not get executed. However, the advantage of JavaScript is that
it is running locally on the client, so no round trip (e.g. connection to
HTTP server, sending request, receive reply, closing connection) is
required.

Google Maps uses JavaScript where possible to allow for the map to be
scrolled around; but when the user enters an area for which the satelitte
imaging has not yet been downloaded, the JavaScript initiates a connection
to the server to download more content.

Without JavaScript, every movement by even a single pixel would require
a round trip, thus creating "unbearable" lag for the user.

JavaScript was given this name purely for marketing reasons. Developped
by Netscape, the technology was originally called LiveScript. Then, when
Netscape partnered with Sun to promote the concept of "Applets embedded in
web pages", the LiveScript language was renamed to JavaScript (thus creating
endless confusion on these newsgroups about the distinction between
JavaScript and Java). "JavaScript" technically is a collection of languages,
as each browser implements its JavaScript interpreter slightly differently.
Microsoft's Internet Explorer, for example, had something called "JScript"
and it is not certain whether this should be considered a "flavour of
JavaScript", or a different (but similar) technology to JavaScript.
"ECMAScript" is one particular flavour of JavaScript standardized by the
ECMA. Some people will use the terms "LiveScript", "JavaScript", "JScript"
and "ECMAScript" interchangeably.

Also, JSP is normally compiled to bytecode, and the bytecode is run on
the server, whereas JavaScript is normally interpreted, where the JavaScript
sourcecode itself is presented to the interpreter (usually embedded within a
web browser) and no extra compilation step is nescessary.

Here's "Hello World" in JavaScript:

document.write('Hello, world!');

Here's "Hello World" in JavaScript embedded in HTML:

<html><body><a href="#" onclick="alert('Hello, world!'); return
false;">Hello World Example
</a></body></html>

Here's "Hello World" in JSP:

<html><body><%="Hello World!" %></body></html>

- Oliver
 
T

Tim Slattery

Robert M. Gary said:
I've noticed in several forums that people are making a clear
distinction between Javascript and JSP. I guess I've used the terms
interchangably. I can't seem to find anything in Google to describe
what might be different between the two.

JSP = Java Server Pages. That's a server-side technology where you use
Java statements to tell the server how to prepare the HTML that's to
be sent to the client.

Javascript is a client-side scripting language. It's read and
interpreted by the client's browser to make the page do various
interesting things after it's arrived at the client.

Javascript != Java. Despite the similar names the languages have
nothing whatsoever to do with each other.
 
R

Robert M. Gary

Awesome! Thanks everyone. It may sound strange but I've managed to work
in Java and C++ for more than 10 years now and am just now getting into
web based stuff. I've always worked on backend telecommunications
projects where no one wanted web based stuff. Now I'm working on my own
web page (www.portfoliomodeler.com) and am getting to play with the web
based side of things. I'm familiar with EJB technologies but it turns
out that GoDaddy doesn't support J2EE stuff.

-Robert
 
H

Hal Rosser

Robert M. Gary said:
I've noticed in several forums that people are making a clear
distinction between Javascript and JSP. I guess I've used the terms
interchangably. I can't seem to find anything in Google to describe
what might be different between the two.

-Robert

JavaScript is executed on the user's browser. JSP executes on the server.
(exception would be the rare example of someone using javascript in ASP
pages)
JSP (simply put) is a program that executes on a server, then sends the
output to the user's browser. The output can contain javascript with the
html.

There is so much difference, that they are not even related.
 
R

Roedy Green

I've noticed in several forums that people are making a clear
distinction between Javascript and JSP. I guess I've used the terms
interchangably. I can't seem to find anything in Google to describe
what might be different between the two.

They are totally different languages. JavaScript run inside a browser
on the client. JSP in a java macro preprocessor than runs in the
server.
 
L

Luke Webber

Robert said:
Awesome! Thanks everyone. It may sound strange but I've managed to work
in Java and C++ for more than 10 years now and am just now getting into
web based stuff. I've always worked on backend telecommunications
projects where no one wanted web based stuff. Now I'm working on my own
web page (www.portfoliomodeler.com) and am getting to play with the web
based side of things. I'm familiar with EJB technologies but it turns
out that GoDaddy doesn't support J2EE stuff.

Actually, JSP is a part of the J2EE servlet spec. It might be more
correct to say that GoDaddy doesn't support /all/ of the J2EE stuff.

Luke
 
R

Robert M. Gary

GoDaddy doesn't support /all/ of the J2EE stuff

I think that GoDaddy is running tomcat for the Java servers (they also
offer .NET). My understanding is that Tomcat does not support the use
of EJBs and that JBoss or similar is required for that.

-Robert
 
S

Steve Sobol

zero said:
the easiest way to see the difference is one simple sentence: JSP runs on
the server, JavaScript runs on the client.

Additionally, Javascript isn't actually Java, it's an approximation thereof.
Javascript looks like Java but only has a small subset of Java's features.
Actually using client-side Java would require you to write an applet.
Furthermore, JSP uses Sun's Java technology. Despite the name, JavaScript
has little to do with Java - the syntax just looks a little alike, but then
so does C++

Eh, Javascript is much closer to Java than C++ is.

The proper term is actually ECMAscript, no?
 
S

Steve Sobol

Robert said:
I think that GoDaddy is running tomcat for the Java servers (they also
offer .NET). My understanding is that Tomcat does not support the use
of EJBs and that JBoss or similar is required for that.

Right. Tomcat is just a container for a web-app. JBoss is a full-blown
application server. JBoss installs, by default, include a copy of Tomcat
(some older versions include Jetty instead).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top