This appendix contains information about converting Server-Side JavaScript™
applications to JSPs. It has the following sections:
•
Differences Between JavaScript and Java
•
JavaScript to Java Class Conversions
•
Conversion Steps
•
Example Conversion
Differences Between JavaScript and Java
Before you can convert SSJS applications to JSPs, you must understand the
differences between JavaScript and Java. JavaScript and Java are similar in some
ways but fundamentally different in others.
JavaScript lacks Java's static typing and strong type checking. JavaScript supports a
runtime system based on a small number of data types representing numeric,
Boolean, and string values. Java has a compile-time system of classes built by
declarations.
JavaScript also supports functions without any special declarative requirements.
Functions can be properties of objects, executing as loosely typed methods. In Java,
methods are defined in and belong to classes, and they are strongly typed.
JavaScript is a very free-form language compared to Java. In Java, you must declare
all variables, classes, and methods. You must declare methods as public, private, or
protected. Variables, parameters, and method return types are explicitly typed.
Converting SSJS Applications
Appendix B
103
Need help?
Do you have a question about the NETSCAPE ENTERPRISE SERVER 6.0 - PROGRAMMER GUIDE TO SERVLETS and is the answer not in the manual?
Questions and answers