aspose file tools*
The moose likes Servlets and the fly likes Doubts about Servlets and JSP(Please explain all my doubts with examples clearly) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Doubts about Servlets and JSP(Please explain all my doubts with examples clearly)" Watch "Doubts about Servlets and JSP(Please explain all my doubts with examples clearly)" New topic
Author

Doubts about Servlets and JSP(Please explain all my doubts with examples clearly)

Poornima Visvesvaran
Greenhorn

Joined: Sep 06, 2000
Posts: 6
Hi friends,
I have lot of doubts regarding servlets and jsp. Can any one explain me.
1. What is the difference between servlets and jsp. As I know both are server side
programming. But please explain me which is powerful and where can I use servlets and
where I use JSP. Please don't explain me the syntax (ie programe code) difference of both.
Just explain me the interior usage of both.
2. Is it possible to run the servlets in IIS. If yes, Please explain me how to run ie how to set
the configuration etc.
3. Servlets are multithreaded by itself. ie On each request, a new instance will be created.
Then, why we have to make the jdbc part in synchronized mode. Because as i heard if we
have not done jdbc part as synchronized then there will be error in data will arise.
4. how an applet communicate with a servlet
5. how a servlet communicate with another servlet. Is it same as servlet chaining. If
communication between two servlets is different from servlet chaining, Please explain me
both the concepts with example programe code.
6. I want to become a master in Servlets and JSP. Suggest me a book for Servlets and JSP.
Is there any book common to both these or shall I buy separate books. Give me name of the
books for Servlets and JSP.
7. what is tomcat? Why we need that? why not we use java web server?
My email address is poornima_visu@yahoo.com
Thanks in advance.
Poornima Visvesvaran.
Mirko Froehlich
Ranch Hand

Joined: Aug 21, 2000
Posts: 114
Hi Poornima,
I'll try to answer all your questions.
1.
See my reply in the following thread: http://www.javaranch.com/ubb/Forum7/HTML/001153.html
JSP is mainly a different way of writing servlets, because JSP pages are internally compiled into servlets. If you are mainly concerned about presentation, JSP is the best choice, since it allows you to embed Java code in an HTML page, as opposed to servlets, which allow you to embed HTML (or other) output in a Java class and are thus more appropriate for pages that are mainly concerned with processing. Often you might want to use both JSP and servlets in the same web application, it is mostly a matter of style.
2.
IIS is only a web server, you need a servlet engine (e.g. JRun) in order to be able to use servlets and/or JSP. At work I am using IIS with JRun, but I am not too familiar with other servlet engines for IIS.
3.
I'll have to pass on this question. I am not sure if the servlet engine really always instantiates a new servlet, though.
4.
I have not done this myself, but just like a browser showing an HTML page, an applet should be able to make an HTTP request to a servlet.
5.
Yes, I believe you are right and communication between servlets goes through servlet chaining. All of this is abstracted in JSP pages, which allow you to include or forward to other JSP pages, which internally uses servlet chaining too.
6.
I don't know too many JSP books - at the time I was learning JSP (a little over a year ago) there were almost no books on JSP at all. Now I mostly know JSP anyway and don't really look at JSP books a lot any more. :-)
"Core Servlets and JavaServer Pages" seems to be a good book to learn JSP and servlet programming. I also found "Java Server Programming" very good for Java server-side programming in general, even though it is slightly outdated and does not cover JSP 1.1 and Servlets 2.2, and only very little JSP in general. And I am sure William Brogden's new book is very good, but I have not had a chance to look at it yet.
7.
Tomcat is the Apache group's free implementation of a servlet and JSP engine, and it is also the reference implementation of the Servlet 2.2 / JSP 1.1 standard. It is only one alternative among many, though. As I said above, you can also use something like JRun, both with Apache and with IIS. Tomcat can be used standalone, i.e. it has an integrated webserver, even though it is not optimized to serve static content. For development purposes, running Tomcat in standalone mode is probably suffucient, and for production you might want to use it together with Apache. Java Web Server is a commercial webserver from SUN.
I hope this helps.
-Mirko

Originally posted by Poornima Visvesvaran:
Hi friends,
I have lot of doubts regarding servlets and jsp. Can any one explain me.
1. What is the difference between servlets and jsp. As I know both are server side
programming. But please explain me which is powerful and where can I use servlets and
where I use JSP. Please don't explain me the syntax (ie programe code) difference of both.
Just explain me the interior usage of both.
2. Is it possible to run the servlets in IIS. If yes, Please explain me how to run ie how to set
the configuration etc.
3. Servlets are multithreaded by itself. ie On each request, a new instance will be created.
Then, why we have to make the jdbc part in synchronized mode. Because as i heard if we
have not done jdbc part as synchronized then there will be error in data will arise.
4. how an applet communicate with a servlet
5. how a servlet communicate with another servlet. Is it same as servlet chaining. If
communication between two servlets is different from servlet chaining, Please explain me
both the concepts with example programe code.
6. I want to become a master in Servlets and JSP. Suggest me a book for Servlets and JSP.
Is there any book common to both these or shall I buy separate books. Give me name of the
books for Servlets and JSP.
7. what is tomcat? Why we need that? why not we use java web server?
My email address is poornima_visu@yahoo.com
Thanks in advance.
Poornima Visvesvaran.

Raghavendra Holla
Ranch Hand

Joined: Jun 02, 2000
Posts: 58
For Point (4)
Applet to Servlet communication will be done via HTTP tunneling. Look into any Servlet books for HTTP tunneling (Better look into book by James Goodwill).
For point (5)
Servlet Chaining is Just a pipeing concept. However servlet to servlet communication is just like Applet to Applet communication. i.e using servletContext object.
for eg in servlet srv1
Servlet2 s2 = getServletContext.getServlet("Servlet2");
will get to object handle. you can call any public method then onwards.
or
another way is using Requestdispachter object. This works only with JSDK 2.1 and above versions.
This again uses Servlet Context object and creates request dispacther object.
In Servlet1
RequestDispatcher rd=getServletContext().getRequestDispatcher("/servlet/Servlet2");
rd.include(request,response);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubts about Servlets and JSP(Please explain all my doubts with examples clearly)