ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Introduction to Java Server Pages:

Updated on November 6, 2014

Understanding the JSP techniques and uses:

When we talk or think about dynamic websites, there are some techniques which come in our mind. They are PHP, ASP.NET, and some other CMS are being used to design dynamic websites. Like these there are JSP and Java Servlets, Java Server Pages (JSP) and Java Servlets both are complementary techniques, these are used to build a fundamental part of the Java 2 Enterprise Edition (J2EE). J2EE is being used in a wide-ranging platform in the field of Enterprise development. By the help of these techniques we can build lot of APIs, a run time platform, and an ideal model for how to combine them in a best way. To take advantage of their features as scalable, portable, and well-developed applications.

We use localhost server to run the applications on our local computers. When we designed the websites so we don’t need to do anything for the website execution. Because everything is ready to use on server where we want to host our website.

There are list of servers which are being used for JSP and Java Servlets:

  1. Glassfish.
  2. Tomcat

These two are being used for the JSP webpages. You can download them from these links as if you want to use the Glassfish server so use this link: and if you want to use Tomcat server, it’s Apache product and its dedicated to JSP or Java Servlets as a localhost server. You can download it from this link:

NOTE: sometimes it become difficult to install the servers for the dedicated technologies. I will suggest that when you are installing your IDE, for example if you are using Netbeans so during the install it will ask you about the servers to be install. So you can install them fully easy during the installation of the Netbeans installation. And it will set each thing by itself just what you will do after the installation. Go to create a new project and design it, and then run it. Your project will run successfully without any kind of errors related to server.

Benefits of the JSP:

There are lot of advantages of the JSP should be use. As we can use the JSP to the premise of what it built. That is to make less hard work for the developers to develop a website as dynamic in a possible way. We can use Java Programming inside the html tags to build dynamic website. It is a great feature of the JSP to design website using the Java Enterprise Technology. The developers are using the JSP as an Enterprise Technology to make satisfy of their customers. It is easy to search the problems of JSP, don’t go anywhere just use the Oracle’s website it will teach you as well as tell you the right and correct solution of your website problem. You can learn lot of things, because they are updating their official website day by day. So go and learn you can use this link:

Why JSP is necessary?

When we discuss about the webpages design programming. So there are lot of applications which are being used online. As they are being used for online transactions, updating, modifying etc. if we use JSP or servlets it will be a good choice due to its functions in networking and advantages of the easy development.

Comparison of JSP with other technologies:

If we simply compare JSP and Java servlets with each other so Java Servlets are so fast to be browse or execute than the JSP. It was a good platform to use the CGI, when the intrepid developers start writing their own server extension by the CGI. But there were also few of challenges. CGI was inefficient and complex scripting language. Active Server Pages (ASP), Microsoft tried its best to give relief the intrepid developers to write codes for the dynamics websites and use the extensions of the servers in their websites. But the ASP sometimes become the reason to crash and hang servers. So in this situations your website will not able to accessible. But the sun’s microsystems make it easy for developers to design and use the extensions of the servers.

To avoid the misconceptions of JSP:

There are lot of questions which are being asked by the developers which are new developers in the field of website designing. They mostly ask the experts as:

  1. How I can use swing component in JSP?
  2. How I can insert images in JSP?
  3. Tomcat is not supporting JavaScript I can’t use images as animation image?
  4. Sometimes browsers not support JSP?


  1. Just simply use the applet and insert the Applet tag in your website
  2. Just simply use the IMG tag to insert your images, don’t need to use any I/O functions.
  3. Using JavaScript to change the images by the help of the mouse movement, so it will not happen due to server is running.
  4. It is not an issue the JSP webpages not viewing on web browsers, because they just show the output of the JSP. You should check the HTML tags.

Lifecycle of the JSP:

Understanding the lifecycle of JSP is easy and simple, the low-level functionality follow these paths:

  1. Compilation
  2. Initialization
  3. Execution
  4. Cleanup

JSP Life Cycle

Figure 1 Four Major Phases of JSP lifecycle
Figure 1 Four Major Phases of JSP lifecycle

Description of the JSP Paths of functionalities in JSP lifecycle:

  1. i. Compilation:

We need a localhost as a server to execute or compile the JSP pages on our local system. We use tomcat server to compile the JSP pages. During the execution of the JSP pages the server check the pages, rather executed or not. And also checks the last updated data on the pages. There are few steps which are being used to be processed the JSP pages.

  1. Parsing the JSP pages.
  2. Turning the JSP pages with servlet.
  3. Compiling the servlet.
  4. ii. Initialization:

There is a method which is used to initialize the JSP pages to invoke. The jsplnit() method is used for this purpose. And we should know the initialization once happen.

The syntax of the function is:

[code language="jsp"]

Public void jspInit(){

//statements here…



  1. iii. Execution:

This phase will be active till the JSP request is not destroy. During the execution the JSP engine calls a JSP method to invoke or load the JSP pages. That’s why we use HttpServletRequest and HttpServletResponse in the JSP programs. The _jspService() method syntax is:

[code language="jsp"]

Public void _jspService(HttpServletRequest request, HttpServletResponse response){

//statements here….



  1. iv. Cleanup

This is the phase which is called destruction in the JSP life cycle. There is a function which is jspDestroy(), it is equivalent to the destroy method of the servlets. We commonly override this methods, if we need to clean up the screen after the execution.

Syntax of the method:

[code language="jsp"]

Public void jspDestroy(){

//statements here



Java Server Pages Tags:

There are total five tags which are being used in JSP.

  1. Declaration tag
  2. Expression tag
  3. Directive Tag
  4. Scriptlet tag
  5. Action tag

Declaration tag:

This tag is used to declare variables or methods any time during the development of the webpages. Syntax is:

[code language="jsp"]


Private String name = “JSP webpages”;




    0 of 8192 characters used
    Post Comment

    • profile image


      3 years ago

      hello, friend i need one more about JSP...please do it as early as you can


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)