aspose file tools*
The moose likes Servlets and the fly likes What are JSP and Servlets, and how do they interact? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "What are JSP and Servlets, and how do they interact?" Watch "What are JSP and Servlets, and how do they interact?" New topic
Author

What are JSP and Servlets, and how do they interact?

Serge Plourde
Ranch Hand

Joined: Jun 23, 2000
Posts: 140
I still did not "touch" to these topics, but I am curious to learn a bit more about those: what they are and how they interact (if there is such interaction). So, please excuse my question if it sounds too simple!
In addition to this, what are the best books available? Is there "free" stuff on the web to learn those?

[This message has been edited by Serge Plourde (edited April 24, 2001).]
David Freels
Ranch Hand

Joined: Feb 01, 2001
Posts: 102
JSP - JavaServer Pages - HTML files with embedded Java code. JSP files get compiled into servlets upon receiving a request.
Servlets are java files that basically replace CGI scripts. Servlets are loaded into memory and threaded for each request that is recieved.
Both technologies require an engine to run in such as JRun or Tomcat.
Further information can be obtained from http://www.javasoft.com/products/servlet/index.html and http://www.javasoft.com/products/jsp/index.html
David
Sun Certified Programmer for the Java2 Platform
Serge Plourde
Ranch Hand

Joined: Jun 23, 2000
Posts: 140
Thanks David!
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Also check Servlets and JavaServer Pages (JSP) 1.0: A Tutorial - the whole book online!

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Dustin Marx
Ranch Hand

Joined: Mar 06, 2001
Posts: 40
A common method of mixing JSPs and Java servlets is to have a Java servlet act as a controller and have views and models implemented as JSPs (Model-View-Controller design pattern, also sometimes referred to as Model 2 JSP approach). The controller can call the appropriate JSPs by utilizing a RequestDispatcher and the RequestDispatcher's forward() method or include() method.
See http://java.sun.com/products/servlet/2.1/api/javax.servlet.RequestDispatcher.html for more details on RequestDispatcher.
sachin dabhade
Ranch Hand

Joined: Mar 10, 2001
Posts: 73
you can have a look for servlets at www.servlets.com www.serverside.com (or probably theserversideside.com)
there are also goos resources available at www.webappcabaret.com/sachin123
Serge Plourde
Ranch Hand

Joined: Jun 23, 2000
Posts: 140
Thanks, all of you. Those are all great suggestions and links!
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi,
JSP is designed to make the life of the programmer easier.Using servlets you can do lots and lots of complicated stuff, but you never tend to use all of them.If that is the case, JSP is the place where you should start from.
By design JSP sits on the top of the servlets.What this means is when you write a JSP code and execute it the JSP Engine complies the JSP page as a servlet, and then makes the class file for it.After that the normal life cycle of the servlet, viz. init(), service() and destroy() follows.
One more advantage of using JSP rather than Servlets, is that,it seperates static content from dynamic content.This means the HTML code can be designed in parallel with the dynamic code that is generated by the JSP tags.This allows Web developers to work in co-ordination with the Java Developers.
Java Developer could make JavaBeans to be used by the Web Developers, who simply use it to generate the dynamic content.The inherent advantage you have with a JSP design is you seperate the business logic from the presentation logic making your page causing lesser maintenance problems.
Hope this helps.
Regards,


------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56


<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Serge Plourde
Ranch Hand

Joined: Jun 23, 2000
Posts: 140
Thanks Sandeep
 
jQuery in Action, 2nd edition
 
subject: What are JSP and Servlets, and how do they interact?