Jsp Tutorial

Jsp Tutorial

Jsp is an acronym of java server page . it is a server-side technology.it is used to create Web-based applications just like Servlet technology, Jsp is an extension to the Java servlet technology that was developed by Sun Microsystems.Jsp technology  provides more functionality than servlet technology such as JSP Standard Tag Library(jstl),Expression Language(EL), Custom Tag  etc.JSP is similar to PHP and ASP, but it uses the Java programming language.

Jsp technology and servlet technology are opposite to each other in the sence , jsp contains java code inside Html code but servlet contains Html code inside java code. The jsp pages are easier to maintain as compare to servlet because we can separate presentation logic and business logic.

In simple word JavaServer Pages (JSP) technology provides a simplified, fast way to create web pages that display dynamically-generated content.

Note:-JSP pages are saved having extension .jsp .

Jsp Life Cycle

When client such like as browser makes a request to Server,then  first request goes to container. Then container checks whether the corresponding servlet class is load or not.if servlet class is not load then container does the translation again (converts JSP to Servlet) otherwise it skips the translation phase.

Following steps are invoked  in  jsp  life cycle:

  1. Translation
  2. Compilation
  3. Loading
  4. Instantiation
  5. Initialization
  6. RequestProcessing
  7. Destroy

 

 Simple JSP  Example

To create the first jsp example in apache tomcat server.

1.open notepad  and write html code as given below.

Screenshot (13)

2.Save file with name index.jsp .

3. Now go in the webapps directory in apache tomcat.

Screenshot (11)

4.Create folder inside webapps directory of Apache tomcat amd put index.jsp file inside the folder. suppose you create folder having name jsp .

Screenshot (12)

 

How to run a simple JSP Example .

Following steps to execute  JSP Example:

1.Start Apache tomcat server.

2.Open browser like chrome and write in  url bar of browser  http://localhost:portno of server /contextRoot/jspfile. e.g   http://localhost:8080 /jsp/index.jsp.

Screenshot (14)

Leave a comment