Showing posts with label jsp. Show all posts
Showing posts with label jsp. Show all posts

Tuesday, September 24, 2013

Difference between servlets and jsp::BrainBitz

JSPServlets
JSP is a webpage scripting language that can generate dynamic content.Servlets are Java programs that are already compiled which also creates dynamic web content.
Servlets run faster compared to JSP.JSP run slower compared to Servlet. JSP compiles into Java Servlets.
It’s easier to code in JSP than in Java Servlets.Its little much code to write here.
In MVC, jsp act as a view.In MVC, servlet act as a controller.
JSP are generally preferred when there is not much processing of data required.servlets are best for use when there is more processing and manipulation involved.
The advantage of JSP programming over servlets is that we can build custom tags which can directly call Java beans.There is no such facility in servlets.
We can achieve functionality of JSP at client side by running JavaScript at client side.There are no such methods for servlets.

Java Web development concepts using Eclipse IDE::BrainBitz

Eclipse Web Tool Platform (WTP)
This tutorial describes the development of servlets and JSPs with Eclipse WTP. 

1. Eclipse Web Tool Platform

Eclipse WTP provides tools for developing standard Java web applications and Java EE applications. Typical web artifacts in a Java environment are HTML pages, XML files, webservices, servlets and JSPs. Eclipse WTP simplifies the creation these web artifacts and provides runtime environments in which these artifacts can be deployed, started and debugged.
In Eclipse WTP you create Dynamic Web Projects. These projects provide the necessary functionality to run, debug and deploy Java web applications. If you are completely new to Java web development you may want to read Introduction to Java Webdevelopment .
Eclipse WTP supports all mayor webcontainers, e.g. Jetty and Apache Tomcat as well as the mayor Java EE application server. This tutorial uses Apache Tomcat as a webcontainer.

2. Tomcat Installation

Apache Tomcat Tutorial for instructions how to install Apache Tomcat.
After the installation test if Tomcat in correctly installed by opening a browser to http://localhost:8080/. This should open a information page of Tomcat.
Afterwards stop Tomcat. Eclipse WTP needs to start Tomcat itself for its deployments.

3. Installation of WTP

In case you have downloaded an Eclipse version for Java development, you can update it via theEclipse Update Manager . Install all packages from the category "Web, XML, Java EE Development and OSGi Enterprise Development" except "PHP Development" and the "RAP" Tooling.
For an introduction in the Eclipse IDE please see the Eclipse IDE Tutorial .

4. WTP Configuration

4.1. Setting up runtime environments

To configure Eclipse WTP select from the menu Window → Preferences → Server → Runtime Environments. Press the Add button.
Select your version of Tomcat.
To compile the JSP into servlets you need to use the JDK. You can check your setup by clicking on theInstalled JRE button.
Press Finish and then OK. You are now ready to use Tomcat with WTP.

4.2. Server

During development you will create your server. You can manageprobably you server via the Serverview .
You can stop and start the server via the Window → Show View → Servers → Servers menu menu.