Saturday, March 28, 2015

JSPs & Servlets Introduction

JSPs & Servlets

Jsp & Servlet are core Java technologies that are used in web development. To start of web development we will need the following tools:
  1. Application Server - Apache Tomcat
  2. An IDE - Eclipse, Netbeans or IntellijIdea ()
  3. Java Runtime Environment (JRE)
Prerequisites:
  1. Basic Java knowledge
  2. HTML (Preferred)
What is Java Server Pages(JSP)?
JSP is a HTML page where java code can be embedded onto it.
Hello World JSP

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <!--  Expression Tag -->
    <%= "Hello Wolrd" %>
</body>
</html>

Steps to do :
  1. Create a web project
  2. Add a new JSP Page under the Web Content Directory of the project
  3. Copy & Paste the above code 
  4. Save & Select the JSP
  5. Run the JSP
Notes:
  • Assuming that you use Eclipse IDE to run your project.