What is a JSP in Java J2EE.
Points To Remember
- JSP stands for Java Server Pages.
- Jsp at compilation time is a servlet and also behaves like a servlet.
- Jsp serves as views in MVC architecture.
- Jsp can contain HTML code inside them.
- They are compiled everytime they are requested.
What is a JSP ?
JavaServer Pages (JSP) is a technology for developing dynamic web pages with dynamic data. You can write java code within a jsp along with the Html using special Jsp tags most of which start with <% and end with %>.A JavaServerPage component is a type of Java servlet that is designed to fulfill the role of a user interface for a Java web application. Web developers write JSPs as text files that combine HTML or XHTML code, XML elements, and embedded JSP actions and commands.
Using JSP, you can collect input from users through web page forms, present records from a database or another source, and create web pages dynamically. JSP tags can be used for a variety of purposes, such as retrieving information from a database or registering user preferences, accessing JavaBeans components, passing control between pages and sharing information between requests, pages etc.
Sample JSP Structure
<%@ 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> This is the body of the jsp page. </body> </html>
No comments: