Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Internet programming...

Options
  • 28-01-2002 2:36pm
    #1
    Posts: 0


    Hey folks,
    Could anyone explain to me please, what exactly a servlet is?
    what's the difference between a servlet and a server?

    Also, i read that cgi programming can be done in any langugage, does that mean that Java could be a suitable language for such interactivity or is perl usually the best one to use?

    I'm trying to get into online programming and interactivity with web pages.

    Thanks in advance for the help


«1

Comments

  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Hi MoonHawk,

    A servlet is just a java program that spits out a HTTP header and HTML. It runs inside a servlet container like Tomcat (http://jakarta.apache.org/tomcat) which would be the server.
    JSP is a type of Java Servlet but it's better suited for display, whereas a servlet is better suited for processing. A JSP is just like a PHP or ASP page, you can embed Java code inside your HTML.
    A JSP page is in face turned into a servlet before it's compiled but it's a lot easier to embed Java in HTML than it is to write HTML with out.println()'s.


    Perl is always associated with CGI programming but any language that can process text is suitable. Perl was the best choice for CGI programming for a long time but now there are other options like PHP, ASP and JSP.

    If you already know Java then I'd advise you to go download Tomcat and start playing with JSPs and servlets. They're really both quite easy. If you don't know Java then PHP is probably the best option as it's one of the more popular languages used for web programming.


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by MoonHawk
    Hey folks,
    Could anyone explain to me please, what exactly a servlet is?
    what's the difference between a servlet and a server?

    I'm sure there are more qualified descriptions out there, but effectively a "servlet" is a program which runs on the server, typically providing a discrete set of functionality, extended from the server itself. It is not a standalone program as it is tied inextriacablty to the running of the web-server.

    Also, i read that cgi programming can be done in any langugage, does that mean that Java could be a suitable language for such interactivity or is perl usually the best one to use?

    In theory, you could use any language for cgi programming. Java is a valid option, but one you wont see used much. Why? Simple - because cgi programming is only one way of interacting with the server, and Java is more suited to using other methods of interaction (such as via JSP).

    I'm trying to get into online programming and interactivity with web pages.
    Without more information, its hard to recommend one approach over another. In truth, there is very little to choose between most of the major approaches other than personal preference, and maybe suitability for a specific task.

    jc


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    In theory, you could use any language for cgi programming. Java is a valid option, but one you wont see used much. Why? Simple - because cgi programming is only one way of interacting with the server, and Java is more suited to using other methods of interaction (such as via JSP).

    Isn't a servlet a CGI program?


  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    An example of a web application (programmed using CGI/Servlets/JSP/PHP etc) could be the Boards.ie website itself. You are frequently presented with HTML forms, in which you fill out and submit. Have you ever wondered what happens that information you submit, and what happens to it?. Well that's where Servlets/JSPs.... come in!.

    Web applications are used to generate dynamic content, such as reading info from a database and then formatting it as HTML output, which can be rendered on your web browser. To your browser (such as IE/Netscape) the output is the same as if it was a standard *.htm/*.html document. Once it output leaves the server it's all just HTML/client based scripts.

    A this point I think everything has been mentioned by Bonkey & Enygma ;)

    ;-phobos-)


  • Closed Accounts Posts: 1,295 ✭✭✭Meh


    Originally posted by Enygma
    Isn't a servlet a CGI program?
    No. Neither are PHP, ASP or JSP.
    CGI = Common Gateway Interface. An obsolete method of web programming, where the web server starts up a new process for every new request that comes in (very inefficient). If someone suggests you use CGI for a web project, fire them. With servlets written in Java, a Java server process listens for incoming requests and uses an existing thread from a pool of idle threads to handle each request (much more efficient).
    You could in theory use Java for CGI programming, but you would be insane to do so, with the entire JVM having to be loaded for every incoming request.


  • Advertisement
  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Ahhh, my idea of a CGI program was a *something* that ran on the webserver and spat out HTML. :rolleyes:
    Thanks for clearing that up :)


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Isn't a servlet a CGI program?

    No. It's also important to point out that PHP isn't necessarily a CGI program either, although it can be run as one. Webopedia will probably explain it all far better than I could:

    http://www.webopedia.com/TERM/s/servlet.html
    http://www.webopedia.com/TERM/C/CGI.html
    http://www.webopedia.com/TERM/P/PHP.html
    http://www.webopedia.com/TERM/J/JSP.html
    http://www.webopedia.com/TERM/A/Active_Server_Pages.html

    adam


  • Registered Users Posts: 2,660 ✭✭✭Baz_


    wow, thanks for that info meh, of course it has completely changed my whole plan for my website setting me back some time, but it is very good to know non-the-less.


  • Posts: 0 [Deleted User]


    Thanks for the replies all,

    I was playing around various different programming thingys today, I was learning how to graphically program in Java (learning how to make JFrames and things like that...hardest thing is to remember all the different constructors and all that) and also, I was playing around with raw HTML (not real programming i know but still good to know), I want to get to know how to do good pages.

    I read up an JSP and servlets and all that, and although some of you may say that it's inefficient, I think that , for learning purposes, I'll just expand my java knowledge and stick with that for a while, just to get into it, as, up until now, I found the idea of CGI kinda abstract but it's making more and more sense.

    it's great trying to experiment with different ideas, so i'll mess around with a few things...for now , i'll look at other cgi's and see how they're implemented.

    thanks for the help all!


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    In theory, you could use any language for cgi programming. Java is a valid option, but one you wont see used much.

    Erm, CGI programming afaik is different to servlets. Java Servlets have better load balancing then CGI (doesn't spawn multiple servlets for multiple users), and is starting to become the preferred way because of it.


  • Advertisement
  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    MoonHawk, no ones saying that JSP's and servlets are inneficient. The confusion arose when I asked if they're the same thing as CGI which they're not.

    JSP's can be highly efficient and can, if done properly decrease development time too. Go get yourself a copy of Tomcat (http://jakarta.apache.org) or Resin (http://www.caucho.com) and play around with JSP's.

    Some good sites worth visiting regularly are:
    http://www.onjava.com
    http://developer.java.sun.com
    http://www.ijug.org
    http://www.javaworld.com
    http://www.serverpages.com

    Good Luck


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    Mentioned in another thread... Forte 3.0 (free from java.sun.com ) comes with Tomcat built in.

    Just download that. :)


  • Registered Users Posts: 16,413 ✭✭✭✭Trojan


    Does nobody do any real programming any more?

    *sigh*

    Al.


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    What is real programming? (punchcards?)


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    I always thought it was the type of programming that made you a better person :p


  • Registered Users Posts: 16,413 ✭✭✭✭Trojan


    Originally posted by Hobbes
    What is real programming? (punchcards?)

    I think we've moved on from that :)

    Al.
    Even Unix might not be as bad on Real Programmers as it once was. The latest release of Unix has the potential of an operating system worthy of any Real Programmer-- two different and subtly incompatible user interfaces, an arcane and complicated teletype driver, virtual memory. If you ignore the fact that it's "structured", even 'C' programming can be appreciated by the Real Programmer: after all, there's no type checking, variable names are seven (ten? eight?) characters long, and the added bonus of the Pointer data type is thrown in-- like having the best parts of Fortran and assembly language in one place. (Not to mention some of the more creative uses for #define.)


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by Meh
    If someone suggests you use CGI for a web project, fire them.

    This is quite possibly the most intelligent evaluation of CGI performance I've ever heard. Its so good, I'm going to steal it and use it in future :)

    jc


  • Posts: 0 [Deleted User]


    Does anyone feel that, nowadays, programming has become more and more "trendy" and,as such, new languages are coming out which are easier and easier to learn, meaning that less and less things can be done through the language?

    Example:
    Assembly Language Programming...hard to learn, hard to construct great programs in, but great to know when you're well with it.

    But new higher level programming languages seem to be hiding more of the behind the scenes stuff to the programmer because the "nu-programmer" just wants to do cool stuff, rather than understand the computer and the workings of it.

    I personally have no experience with something like C#, but that's the impression i get from languages such as that.

    I love using Java, i think it's great that amazing things are possible with it, but I can't help feeling like we're missing out on something with these new languages...any one feel the same?
    :confused:


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    I know what you mean, but to be honest, most of the time I'd rather get things done than mess about with memory allocation and stacks etc.

    Is there anything wrong with that? Hardly.

    Of course newer languages are going to hide the details from you, it allows you to get the job done quickly and easily. If they didn't, they wouldn't be successful.

    Would you prefer a world without Java or C# or any of the other newer languages? Would you rather everyone had to write applications in assembly or FORTRAN?

    But new higher level programming languages seem to be hiding more of the behind the scenes stuff to the programmer because the "nu-programmer" just wants to do cool stuff, rather than understand the computer and the workings of it.

    Same way people drive their cars everyday without understanding the engine, and the same way people use their computers every day without understanding how it works, and the same way people watch TV without understanding how that works.


    A programming language that makes something easy isn't necessarily a bad thing, VB makes GUI programming easy, Perl is great for processing text, Java makes it easy to port to other architectures.


    Personally I'd rather not know every little detail about my machine, I'd rather get the job done.
    There's no room for an elitist attitude when it comes to nailing a deadline.


  • Posts: 0 [Deleted User]


    Yeah I can see your point alright, it's just my idea of programming used to be this notion of some genius who knew it all (almost all the languages).

    Now I know that it's impossible to know everything, I'd just like to know one thing well if you know what I mean, rather than do a bit of it and then leave it...maybe that's what I was getting at (i'm confusing myself!)

    eg. I'd hate to learn a bit of c++ and then leave it, to do something in another language (if i had to)...i'd be the type to finish what i was learning and then move on.


    But I've found out that it's not the way to do things...there's just not time to get everything done like that.

    :confused: My head hurts now! :p


  • Advertisement
  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Just learn what you need to learn when you need to learn it, in five years time you'll look back and be amazed, and in ten years and twenty...

    dont' stop learning in other words :)


  • Registered Users Posts: 258 ✭✭peterd


    Does anyone feel that, nowadays, programming has become more and more "trendy" and,as such, new languages are coming out which are easier and easier to learn, meaning that less and less things can be done through the language?

    An example of this is could be Escapade (http://escapade.portland.co.uk/). It's like dummy programming for dummies! I've never used it, but from a quick read over the site, it's just using a template file and inserting text. It was first 'trendy' to have your own web site once sites came out with simple DIY tools and free webspace. Now everyone can be a programmer.

    [edit] wrong url


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Does anyone feel that, nowadays, programming has become more and more "trendy" and,as such, new languages are coming out which are easier and easier to learn, meaning that less and less things can be done through the language?

    Depends on your definition of a language really. Taking PHP as an example, I don't really define it as a programming language - more a scripting language - but it has to be said that it does what it was designed to do particularly well, it has an enormous API that offers a multitude of options, and it's relatively simple to use. Granted, it is a wee bit "trendy", but it does bring down barriers of entry to the field, which has to be a good thing IMHO. It has its downside too, in that you get a lot of dorks asking stupid questions, but most of these either turn into clever coders or just fade away. It has to be said that PHPBuilder was a heck of a lot more fun when PHP was less popular though. Now it's a waste of effort.

    adam


  • Posts: 0 [Deleted User]


    Yeah dahamsta, it's great that more and more programmers are coming into it, there's always someone who has a good idea, the hard part is turning it into a program.

    I find another example of such a tool is Borland JBuilder, which draws your applications and all that, which is cool (i can't imagine designing and drawing every application layout by plain code all the time!) but at the same time,when it comes to debugging, you don't know where or what the methods that the program has put in and you get lost because it's not your code.
    Things like that get to me, it feels like i'm not doing work with it at all and just getting frustrated.

    peterd, following your point, I remember seeing about 4/5 years ago webpages done by people for a laugh, nowadays almost everything incorporates cgi in some form.

    And enygma, i'll take that advice on board, it makes sense to keep learning , adding bits and pieces on to what i know eventually...if i try and do it all at once, i won't be able to and give up.


  • Registered Users Posts: 16,413 ✭✭✭✭Trojan


    ok, so before you tell me, I know I started it.

    That said, I agree with Enygmas practical attitude:
    Originally posted by Enygma

    Personally I'd rather not know every little detail about my machine, I'd rather get the job done.
    There's no room for an elitist attitude when it comes to nailing a deadline.

    But there is room for an elitist attitude when you're in the pub with your Java/C#/html-loving mates, and there is room for an elitist attitude when you're slagging on a BBS :)

    Originally posted by MoonHawk

    I can't help feeling like we're missing out on something with these new languages...any one feel the same?

    Yep, that's why I'm doing system level programming, always have. Much nicer to be mucking about below the application level.
    Originally posted by MoonHawk

    it's just my idea of programming used to be this notion of some genius who knew it all (almost all the languages).

    You must be joking :)
    Check out yahoo.

    Al.


  • Posts: 0 [Deleted User]


    Trojan,
    is that system level programming just assembly programming?

    Assembly is something i'd like to get into (not now but in time, after everything else is done), as it is FAST for simple I/O programs.
    I like it.

    is C# any good or is it another type of hybrid language hacked together?

    and what's this about slagging on a bbs? ;-)


  • Closed Accounts Posts: 1,295 ✭✭✭Meh


    Originally posted by MoonHawk
    Assembly is something i'd like to get into (not now but in time, after everything else is done), as it is FAST for simple I/O programs.
    I like it.
    "Assembly code is fast" is probably the greatest programming myth there is. Sure, back in the old days with non-optimizing compilers, it was possible to squeeze a bit more performance out of your 4 MHZ 68000 using assembly code. But these days, with pipelining, speculative execution, caching and branch prediction, compilers do a much better job of optimizing code than any human could do. Instruction scheduling, cache line alignment etc are all simple mechanical processes that are better done by compilers than by programmers.


  • Posts: 0 [Deleted User]


    Ah right
    well maybe that's the case, that in today's world and fast processors, we don't need assembly...but it's handy to know because you will understand better what the compiler is doing...sure it may be becoming outdated, but what's the harm in knowing what's going on behind the scenes?

    no matter what language you're programming in, it's better practice to write efficient code, rather than clunky, slow code because you've got the "best processor available" and assembly is still valid in terms of efficiency.


  • Closed Accounts Posts: 1,295 ✭✭✭Meh


    Originally posted by MoonHawk
    no matter what language you're programming in, it's better practice to write efficient code, rather than clunky, slow code because you've got the "best processor available" and assembly is still valid in terms of efficiency.
    My point is that compilers generate more efficient assembly code than humans do. It's a much better use of a programmer's time to optimise the algorithm and let the compiler translate it into optimizes assembly, which is what it does best.. I'm not arguing that efficiency isn't needed any more now that we have the PENTIUM 4 that makes the INTARWEB GO FASTAR.


  • Advertisement
  • Posts: 0 [Deleted User]


    Ah right sorry, didn't get your point first time round.

    yeah i agree that the compiler does all that and saves the programmer time with doing the same assebly code over and over...i suppose that's what computers were built for, to automate repetitive tasks.

    There are some things in programming that you dont' want to have to do over and over again, and if you think about how things are being done, then you'll overload your mind...good thing for compilers then...my point is that it's still handy to have an understanding of assembly so you know what the compiler is doing, that you won't be programming without a notion of what it's doing.


Advertisement