Though Servlets were awesome when compared to CGI, they still had some issues when it came to displaying dynamic content on a web page. Thankfully, Sun released the JSP (Java Server Pages) specifications in 1998, which solved all our UI woes. JSPs enabled programmers to display dynamic HTML content that could also use Java features.
JSPs can contain HTML, JavaScript, XML and Java Code whereas Servlets can contain only Java Code, making JSPs more flexible and powerful than Servlets. However, Servlets have their own place in a J2EE application and cannot be ignored altogether. They have their strengths too which cannot be overseen.
The speed difference is not usually significant, but the slight performance advantage goes to Servlets because, JSPs get converted to Servlets before execution and since Servlets do not have this conversion phase, they are a little and I mean only slightly little faster than JSPs
No. But, knowledge of Servlets would be an added advantage if you are learning JSPs
Try the Head First JSP & Servlets book. It is a good book for learning them. You can also try the internet. You can get a lot of websites that give you tutorials on JSPs and Servlets. One of them is available in the related links section
Both are equally used and equally important. They are both used in conjunction. An application usually has 1 or 2 servlets but has numerous JSPs. So, if we go by pure number, JSPs are more.
Servlets were the alternative to CGI and were released in 1997. Unlike CGI, which starts a process for each request, Servlets just spawn a new thread. Servlets had a better or rather efficient architecture which was able to handle the loads of the internet. Though Servlets were awesome when compared to CGI, they still had some issues when it came to displaying dynamic content on a web page. Thankfully, Sun released the JSP (Java Server Pages) specifications in 1998, which solved all our UI woes. JSPs enabled programmers to display dynamic HTML content that could also use Java features. The combination of JSPs and Servlets was just what the Doctor Prescribed and it just revolutionized the Web Programming industry.
== == The basic difference between a web server and an application server is Webserver can execute only web applications i,e servlets and JSPs and has only a single container known as Web container which is used to interpret/execute web applications Application server can execute Enterprise application, i,e (servlets, jsps, and EJBs) it is having two containers 1. Web Container(for interpreting/executing servlets and jsps) 2. EJB container(for executing EJBs). it can perform operations like load balancing , transaction demarcation etc etc
JSPs and Servlets can be used interchangeably for the most part. In fact, when a JSP is compiled, it is actually turned into a servlet! That being said, there are some guidelines for using servlets over JSPs or vice versa. Here are a couple of examples, but by no means a complete list: Typically, you would use a JSP to display dynamic data, or a form. A Servlet is usually what you would want to use to process a post or a get, especially considering the method that is called when you call a servlet (either doGet or doPost). For more information on this, here is a good article on Servlet and JSP Best Practices: http:/java.sun.com/developer/technicalArticles/javaserverpages/servlets_jsp
Yes, JSP (JavaServer Pages) and Servlets can be used together in a web application. Servlets handle the business logic and processing of requests, while JSP is used to create the user interface and generate dynamic content. Servlets can interact with JSP pages to pass data and control the flow of the application.
There is an IDE called WSAD - Websphere Studio Application Developer. It has inbuilt tools to debug everything (servlets & jsps inclusive) I have heard from my friends that Eclipse too has some plugins that can help us debug jsps. The MyEclipse plugin for Eclipse also has tools for debugging Servlets and JSPs. Debugging a JSP in MyEclipse is a little tricky sometimes, depending upon the Java Application Server you are using. In theory, it should not be too difficult to debug a JSP as when it is compiled, it is compiled into a Servlet anyway.
No. I believe, servlets are much secure and more powerful than applets.
Benefits of using Servlets for developing Web Applications:Servlets are an integral part of any J2EE Web application. The key benefits of using Servlets in our web applications are:a. They are faster than CGI scripts because each CGI script produces an entirely new process that takes a lot of time to execute, whereas a servlet creates only a new thread.b. Servlet API is standard and available easily on the internet (like JSPs)c. Servlets have the advantages like ease of development & platform independence (like Java)d. They can access all the J2SE and J2EE APIse. Can take the full advantage & capabilities of the Java programming langauge