• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difference between Servlet, JSP and Java

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Guru's

I am little bit confuse about SERVLET, JSP and JAVA.
If I am using web design for SERVLET with TOMCAT.
Why I want to use JSP and JAVA.

Pls explain to me.

Thanks, Raghu.K
[ October 11, 2006: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MVC - JSP is the View. Servlet is the Controller, and Model is usually just some form of a JavaBean. It's all Java.
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java is a programming language, Servlets and jsps are web technologies built for J2EE (framework|methodology|platform). Tomcat is a popular servlet container used for building web based applications.

For more information visit the sun website at http://java.sun.com
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If I am using web design for SERVLET with TOMCAT.
Why I want to use JSP and JAVA.



If you are "using web design for SERVLET with TOMCAT", then you are using the computer programming language called JAVA to write your SERVLET.

A SERVLET displays html in a browser window using the println() command, and it looks like this:

out.println("<html>\n"
+ "<head>\n"
+ "<title>My html page</title>\n"
+ "</head>\n"
+ ...
+ ...
+ "</html>"

As you can imagine, outputting a whole html page to a browser like that is a big hassle: you have to put quotes around all the html and you have to add a "\n" to output the html on a newline.

Instead a SERVLET can use a JSP page to display the html. A JSP page looks like a normal html page--except that it has a few lines of JAVA in it, for instance:

<html>
<head>
<title>My html page</title>
</head>
<body>
<% String firstname = request.getParameter("firstName"); %>
<div><%= firstname %></div>
</body>
</html>
[ October 11, 2006: Message edited by: sven studde ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
except that it has a few lines of JAVA in it.

Don't let Bear hear you say that.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ragu,

A few points to help you get the most out of JavaRanch as a resource:

1) Please modify your display name to mixed case. The all-uppercase can be construed as "shouting" and may considered rude by some. Our eyes will thank you.

2) "Pls" is not a real word. Please take the time to use real words in your posts such as "please".

thanks!
Bear
JavaRanch Sheriff
[ October 11, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
P.S. I'll save my "scriplets are so yesterday" speech for another time.
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

P.S. I'll save my "scriplets are so yesterday" speech for another time.


I'd like to hear it. Mixing java with html has made me uneasy from the start. This is a discussion forum. Don't be afraid to discuss. Maybe a few alcoholic beverages will loosen those lips.
[ October 11, 2006: Message edited by: sven studde ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sven studde:

I'd like to hear it. Mixing java with html has made me uneasy from the start. This is a discussion forum. Don't be afraid to discuss. Maybe a few alcoholic beverages will loosen those lips.



Stick around and you'll hear it; loud and often.
No drinks needed.



If you'd like to hear Bear's opinions in long form, he's had several articles published in our Javaranch Journal. You can find links at top of the JSP forum.
They're worth reading.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing to note, that throws a wrench into everything, is that at deployment time, there really isn't any difference between Servlets, JSPs and for that matter, Java.

JSPs are simply designed and developed differently from Servlets. However, when JSPs run on the server, the server turns the JSP into a Servlet, and runs the JSP with all of the semantics associated with Servlets running in the web container. You can actually instruct a J2EE application server to save the code that is generated when a JSP is converted into a Servlet at runtime.

With WebSphere, (I'm not sure about the other implementations), it is actually a Servlet running on the server that turns JSP files into Servlets. I alway refer to it as the "BorgServlet", although the name IBM uses is much less creative.

Cheers!

-Cameron McKenzie
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic