Java Server Pages (JSP) Tutorial
Required for creating dynamic and platform independent web applications, JSP is a server-side scripting technology.
Java Server Pages (JSP) TutorialLearn JSP with this most complete and interesting Java Server Pages (JSP) Tutorial. Explaining all the basic and advance concepts of JSP, this tutorial helps you develop web applications easily and quickly. Everything here is taught with practical examples and easy programs.
Who is this JSP Tutorial designed for?This tutorial is designed for Java Programming beginners and professionals who aspire to develop web applications. All freshers, BCA, BE, BTech, MCA and college students will find this tutorial very helpful in taking their skills many steps ahead. You can use also use this tutorial to develop your notes, exam preparation, lab exercises, assignments and viva questions. If you are a professional, you can skip to the advance chapters.
What do I need to know to begin with?Since JSP is about developing web applications, you need to possess some knowledge about web browsers, web servers, HTML and Java programming to get you started well!
JSP syllabus covered in this tutorialThis tutorial covers:
Scripting Element, Implicit Object, Client & Server, Form Processing, Directive Elements, Exception Handling, Action Element, Expression Language, Java Standard Tag Library, Custom Tags.
This covers almost everything you would need to know about JSP. So, let's start learning now!
Introduction to JSP
- Java Server Pages (JSP) is a server-side scripting technology. It helps to create dynamic and platform-independent web-based applications.
- JSP is an extension of Servlet API and given by Sun Microsystems.
- JSP contains HTML tags and can add Java codes inside the HTML.
- JSP separates presentation and business logic as the web designer can update JSP pages without knowledge of Java programming.
- JSP tags start with "<%" and end with "%>".
- JSP is used to collect input from user through web page forms, present records from a database, passing control between pages and sharing information.
Advantages of JSP
- JSP is easy to maintain. It can easily separate business logic from presentation logic.
- JSP is developed on Java language so it is portable to other operating systems.
- JSP is the extension of Servlet. It has a high performance and scalability.
- It reduces the size of code because it uses lots of action tags, custom tags etc.
- JSP provides the fast development because if the page is modified there is no need to recompile and redeploy the application.
Architecture of JSP
Life Cycle of JSP PageThere are following steps in the JSP life cycle:
- Translation of JSP page.
- Compilation of JSP page.
- Loading the class.
- Instantiation of Servlet objects.
- Initialization by calling jspInit( ) method.
- Request Processing by calling _jspService( ) method.
- Destruction by calling jspDestroy( ) method.
- First when web browser asks for JSP, Web container translates JSP code into a servlet(.java) file, then compiler compiles it into .class file.
- In next step the classloader loads the servlet class bytecode.
- Web container calls the jspInit() method to load JSP class. For each request the web container invokes the _jspService( ) method.
- Finally the jspDestroy( ) method is invoked for cleanup.
jspInit( ) method
public void jspInit( )
_jspService( ) method
void _jspService(HttpServletRequest request, HttpServletResponse response)
jspDestroy( ) method
public void jspDestroy( )