Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java on Apache 1

Status
Not open for further replies.

TealWren

Programmer
Jun 7, 2001
231
US
Is there anything that needs to be done to enable Java Script on an apache server?

TealWren
 
Nope, it should work once you setup your Apache client. Well, at least as far as I remember.
 
Is there a certain place that java scripts need to be located? I noticed that in the config file it indicates that for cgi scripts you need a 'shebang line' at the top of each script. Do java scripts need a similar indicator to tell it what program to use?

Thanks for your help!!
TealWren
 
java should work perfectly fine with the apache default install
 
Client-side Javascript is really only plain text, as far as Apache is concerned. It just passes any .js file right to the browser, without any intervention, just like a regular HTML or text page. You should definitely not try to treat plain Javscript as a CGI, since that would make the server try to parse the javascript file, instead of just sending it to the browser.

It is possible to interfere with Apache's default handling of .js files, if you change the javascript setting in your "conf/mime.types" file, or if you try something like "AddType application/x-javascript", or some other such silliness in your httpd.conf file. Resist that temptation, please.

Javascript was originally conceived as both a client-side and a server-side language, and it is possible to still do server-side Javascript in a couple of webservers, but Apache has no server-side handling for Javascript, so any attempt to set special server parsing for Javascript would just cause errors.

On the other hand, you CAN set any kind of file as the SRC attribute of a script tag, so you can actually have javascript output be delivered by a CGI file. That is a different story, though. In that case, there is server-side CGI code, such as Perl, which then outputs valid Javascript to the browser, just as it outputs HTML normally. SOmething like:

Code:
<script language=&quot;Javascript&quot; src=&quot;/cgi-bin/myprogram.cgi&quot;></script>

Let me stress THIS IS NOT SERVER_SIDE PARSING OF JAVASCRIPT; it is server-side parsing of CGI, which delivers text in the form of javascript to the browser. To the browser, Javascript is just plain text, and it doesn't care where it gets it from.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top