aspose file tools*
The moose likes Servlets and the fly likes Difference between Servlet, JSP and Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Difference between Servlet, JSP and Java" Watch "Difference between Servlet, JSP and Java" New topic
Author

Difference between Servlet, JSP and Java

RAGU KANNAN
Ranch Hand

Joined: Dec 16, 2005
Posts: 103
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 ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

MVC - JSP is the View. Servlet is the Controller, and Model is usually just some form of a JavaBean. It's all Java.


GenRocket - Experts at Building Test Data
vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116
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
sven studde
Ranch Hand

Joined: Sep 26, 2006
Posts: 148
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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

except that it has a few lines of JAVA in it.

Don't let Bear hear you say that.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

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

Joined: Sep 26, 2006
Posts: 148
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 ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between Servlet, JSP and Java