Link to home
Start Free TrialLog in
Avatar of Motaz
Motaz

asked on

New in JS, how to run JSP server side in Linux, Apache

I have this sample:

<html>

<body>
<server>
var d = new Date();
h = d.getHours();

Response.Write("<p>");
Response.Write(d + " (Norwegian Time)");
Response.Write("</p>");
Response.Write("Hello " + Request.queryString("name") + '<br>');

if (h <  12)
     {
     Response.Write("Good Morning!");
     }
else
     {
     Response.Write("Good day!");
     }
</server>
</body>

</html>

How can I run it in Windows using Apache 2, in which directory of apache should I save this file, and what is the extesion, and I want to do the same thing in Linux

Also I need a good starting reference for Javascript server side
Motaz
Avatar of dorward
dorward

Your topic, code and words seem to be at odds.

Are you looking for help with ASP JScript (which is like JavaScript) or JSP (which is real Java)? (Java and JavaScript have almost nothing in common except the name). Your code appears to be JScript.

If you want to use JScript under Apache on Linux (maybe for Windows too), then you will need an ASP module such as this one: http://wwws.sun.com/software/chilisoft/index.html

If you want to use JSP, you'll need something like Apache Tomcat: http://jakarta.apache.org/tomcat/index.html
Avatar of Motaz

ASKER

Thanks for the information.
Actually I know a little about JavaScript.
I´ll tell you what I need:

We want to write message board applications that can be hosted in free or inexpensive Linux servers. What did u suggest to use:

1. JavaScript
2. JSP
3. Perl

We can learn new language, so that we need an easy thing and free, we don´t want to buy web servers.

Motaz
Avatar of Motaz

ASKER

Also we assumed that the web server in the host is Apache
I wouldn't use JavaScript for this, the servers are non-free.

JSP is a nice language, but suffers from limited availability. If you can base your choice of host of their supporting JSP then this would be my preference. Apache HTTPD doesn't do JSP though, you would want Apace Tomcat.

Perl is a very mature language with very wide availability. This is probably the best of the choices you've proposed. Apache HTTPD has mod_perl for running Perl scripts quickly without the overhead of CGI.
There are countless ways you can achieve what you want to do, but from your requirements and my experience, I'd suggest using JSP/Servlets on Tomcat/Apache.

Apache is not a servlet container, so you'll need to bolt one on.  Tomcat fits the bill nicely.

When you create your JSPs, there is nothing stopping you from including JavaScript in them.
You can also store the data on MySQL which is easy to deal with using servlets.  In fact using JDBC to talk to the database means that the actual database implementation is not relevant, you could just as easily use Oracle.

But MySQL is free on Linux ;-)  (I think you might have to pay something for it if you run it on an MS platform)
> When you create your JSPs, there is nothing stopping you from including JavaScript in them.

Nothing stopping you from using CLIENT-side JavaScript. You won't be able to execute server side JS with it.

> But MySQL is free on Linux ;-)  (I think you might have to pay something for it if you run it on an MS platform)

Free versions of MySQL exist for MS Windows. You can pay for a nice package with support if you like.
Avatar of Motaz

ASKER

What about Perl CGI applications, is it script or executable?
What about threading, still load instance for every user or there is a different technique

Motaz
ASKER CERTIFIED SOLUTION
Avatar of dorward
dorward

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> What about threading, ...

This is the standard way of managing connections.  I don't think you need to worry about it (unless you want to write your own server).
I thought the standard way was forking? Its only Apache 2 which does threading IIRC.
Doh!

Sorry.  I just use Tomcat in standalone mode and that uses threads.  More "lightweight" than forking as I understand it.

Still, my comment still applies, how it is done shouldn't matter unless Motaz wants to write his own server.
Indeed
Avatar of Michel Plungjan
Message board applications on for example PHP or perl are everywhere

try google
free message board php

Michel
Avatar of Motaz

ASKER

I dowonload ActivePerl from Perl.org
I found a sample program and I can run it using command line :

Perl First.perl

Put I don't know how can I produce executable version if there is an executable version, if it is script language that means I should able to run source using apache.

Motaz
Avatar of Motaz

ASKER

It works in Windows!
the file is httpd.conf not srm.conf, I'm using Apahe2
but still not working in Linux 9 RH, I don't find httpd.conf or srm.conf

Anyway I think it is a small problem and needs alot of search

Really I understand alot of new things David, and really
"the world would be a better place if all web authors practised standards "

Motaz
Avatar of Motaz

ASKER

Last question,
which is better, Perl or PHP!!!!

Motaz
Java ;-)

No, seriously, it depends on what you want to achieve.  I saw a good quote on this somewhere recently.  The author was obviously very good at both and he said:

If I need to achieve something simple quickly I use Perl.  If I need something more complex that I need to come back to later (to maintain or update), then I use PHP.

Sorry, I can't remember where I saw that, I just remembered it ;-)
I think java and jsp is overkill for a message board unless you WNAT to learn and use java
Avatar of Motaz

ASKER

Thanks, that means I should use PHP

Motaz
;-)
Avatar of Motaz

ASKER

jimmack, what is your opinion
Opinion eh? ;-)

Well I've looked at Perl and run away.  I've looked at PHP and it seems OK, but I haven't used it for anything useful.  The majority of my experience is in C++ (which I've also left behind) and for the last 7 years or so Java.

Because I specialise in the development of Java systems, that is what I would use.  But bear in mind that I have no learning curve to consider for either the language or the platforms.  I've developed a complete chatroom application that uses Tomcat4 (standalone) as the server with a J2ME client for mobile phones.  I don't think that it's overkill by any means.  It took about 2 weeks to create the fully working client/server system and then about another 4 weeks to tune it, improve it and rigorously test it.

I haven't been back to the code for about 4 months, but because I documented it throroughly (with javadocs) and because I have a complete test system in place (JUnit/HttpUnit), I am comfortable with the fact that I can pick up where I left off with minimum effort.

If you ensure that you fully understand, document and test your system, it would probably be best to use the language with which you are most comfortable.

Perl, PHP, Java, .NET etc. are all valid choices for what you want to do.  It's more a question of what *you* feel is best suited to your needs, ie. which is easiest for you, which requires the least input of time/effort/money, which will your current systems support best, etc.

Well.  That's my opinion for now ;-)  Hope it helps.
When I said overkill I mean, I have had friends with no programming experience download, install and configure phpbb and other chatand messaging things in 2 hours. To program a chatroom/forum in Java is a GREAT learning experience, but if you are not out for the learning experience, I would go for the download, install and let'er rip
>>  When I said overkill I mean...

That's no problem ;-)  I didn't think you were "having a go" at Java ;-)

And I agree that if you want a working system that is ready to go, there are plenty already available ;-)

Motaz:  Good luck :-)