Solved

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

Posted on 2003-11-05
26
328 Views
Last Modified: 2010-08-05
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
Comment
Question by:Motaz
  • 8
  • 8
  • 7
  • +1
26 Comments
 
LVL 17

Expert Comment

by:dorward
Comment Utility
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
 
LVL 7

Author Comment

by:Motaz
Comment Utility
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
 
LVL 7

Author Comment

by:Motaz
Comment Utility
Also we assumed that the web server in the host is Apache
0
 
LVL 17

Expert Comment

by:dorward
Comment Utility
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
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
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
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
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
 
LVL 17

Expert Comment

by:dorward
Comment Utility
> 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
 
LVL 7

Author Comment

by:Motaz
Comment Utility
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
 
LVL 17

Accepted Solution

by:
dorward earned 300 total points
Comment Utility
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
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
>> 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
 
LVL 17

Expert Comment

by:dorward
Comment Utility
I thought the standard way was forking? Its only Apache 2 which does threading IIRC.
0
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
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
 
LVL 17

Expert Comment

by:dorward
Comment Utility
Indeed
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Message board applications on for example PHP or perl are everywhere

try google
free message board php

Michel
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
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
 
LVL 17

Expert Comment

by:dorward
Comment Utility
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
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
 
LVL 7

Author Comment

by:Motaz
Comment Utility
Last question,
which is better, Perl or PHP!!!!

Motaz
0
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
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
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
I think java and jsp is overkill for a message board unless you WNAT to learn and use java
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
Thanks, that means I should use PHP

Motaz
0
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
;-)
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
jimmack, what is your opinion
0
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
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
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
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
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
>>  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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now