Re: JSP and Servlet




az wrote:
> Anyone can tell me what is the difference between JSP and Servlet?
Thanks a lot!

Servlets are written in pure Java. Requests for a web page go to a Java
program.

JSP's are HTML pages with some Java hacked into them. They are neither
pure HTML nor pure Java. It is a more limited and hybrid environment.

The big question is do you have Java outputing HTML or do you have HTML
trying to hook into code?

JSP's appear to provide some syntactic sugar as a solution, which
sounds nice but the limitations catch up very quickly.

Besides that to know how JSP's work you need to understand the Servlet
API anyway. Application scope, session scope, cookies, ... so it is not
a case of "one or the other".

Servlets can emit HTML and if you're wise you can do it in a tidy
fashion.

Most books and simple examples just do a crude out.print(...HTML
gut...) then go running to JSP for help but only to run from the frying
pan into the fire.

With Servlets you have the full power of a decent OO language at your
disposal, it is possible to do HTML simply and neatly with perhaps a
light dose of JSP.

The other path has led to progressive chaos!

First JSP
Then JSP + Taglibs
Then JSP + Taglibs + JSTL
Then JSP + Taglibs + JSTL + "EL" (Expression Language)
Then JSP + Taglibs + JSTL + "EL" + JSF (JavaServer Faces)

All because some people can't work out how to use OOP to output HTML
from Servlets in a reasonable OOP way.

JSF is to web pages what Swing is to GUI's so it's promising but that
is another topic.

HTH,
Cheers.

.



Relevant Pages

  • Java / J2EE Interview questions
    ... Core Java and OOP's Interview questions ... Servlets / JSP Interview questions ... What’s an interface and how will you go about implementing an ... Servlets and JSP ...
    (comp.lang.java.gui)
  • Re: =?iso-8859-1?Q?Kompatibilit=E4t?= von Konzepten von PHP zu Java
    ... Reine Servlets sind nicht so prickelnd. ... JSP sagen mir wenig zu, genau wie bei PHP ein Gemisch ... aus PHP und HTML. ...
    (de.comp.lang.java)
  • MVC in JSP (was: template in servlet)
    ... JSP = viel HTML mit wenig Java ... ... HTML ins JSP, ... public void setUser(String user) { ...
    (de.comp.lang.java)
  • Re: Need help with Tomcat/JSP website design
    ... so mostly I need help with the JSP side ... I mean, you could just do the whole thing in servlets, but then ... java the language ... your database. ...
    (comp.lang.java.programmer)
  • Re: Java Beginner
    ... Let's say that I have a log in page, created with only HTML code. ... Now in my jsp page I check the validity of my log-in ... --I show all the clients for this Id ... If it's java you're particularly interested in have a look at the struts ...
    (comp.lang.java.programmer)