Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 339
  • Last Modified:

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
0
Motaz
Asked:
Motaz
  • 8
  • 8
  • 7
  • +1
1 Solution
 
dorwardCommented:
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
0
 
MotazAuthor Commented:
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
0
 
MotazAuthor Commented:
Also we assumed that the web server in the host is Apache
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
dorwardCommented:
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.
0
 
jimmackCommented:
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.
0
 
jimmackCommented:
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)
0
 
dorwardCommented:
> 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.
0
 
MotazAuthor Commented:
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
0
 
dorwardCommented:
Perl is almost always script, at least to start with. I suggest you avoid Perl CGI as you get the overheard that CGI causes. Go with mod_perl instead, its much quicker. I won't swear to it, but I believe that the system keeps a compiled version of the script in memory when you use mod_perl.
0
 
jimmackCommented:
>> 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).
0
 
dorwardCommented:
I thought the standard way was forking? Its only Apache 2 which does threading IIRC.
0
 
jimmackCommented:
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.
0
 
dorwardCommented:
Indeed
0
 
Michel PlungjanIT ExpertCommented:
Message board applications on for example PHP or perl are everywhere

try google
free message board php

Michel
0
 
MotazAuthor Commented:
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
0
 
dorwardCommented:
0
 
MotazAuthor Commented:
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
0
 
MotazAuthor Commented:
Last question,
which is better, Perl or PHP!!!!

Motaz
0
 
jimmackCommented:
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 ;-)
0
 
Michel PlungjanIT ExpertCommented:
I think java and jsp is overkill for a message board unless you WNAT to learn and use java
0
 
MotazAuthor Commented:
Thanks, that means I should use PHP

Motaz
0
 
jimmackCommented:
;-)
0
 
MotazAuthor Commented:
jimmack, what is your opinion
0
 
jimmackCommented:
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.
0
 
Michel PlungjanIT ExpertCommented:
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
0
 
jimmackCommented:
>>  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 :-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 8
  • 8
  • 7
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now